@zalom/plastic 1.0.0-alpha.2 → 1.0.0-alpha.4
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.
- package/hooks/hooks.json +0 -11
- package/package.json +1 -1
- package/scripts/hook-session-start +16 -1
- package/scripts/install.rb +15 -6
package/hooks/hooks.json
CHANGED
package/package.json
CHANGED
|
@@ -150,11 +150,22 @@ active_deprecations = deprecations.select do |dep|
|
|
|
150
150
|
!dismissed.include?(dep["id"])
|
|
151
151
|
end
|
|
152
152
|
|
|
153
|
+
# --- Check for available updates (from previous session's check) ---
|
|
154
|
+
|
|
155
|
+
update_notice = nil
|
|
156
|
+
cache_file = "#{store_root}/.cache/update-check.json"
|
|
157
|
+
if File.exist?(cache_file)
|
|
158
|
+
cache = JSON.parse(File.read(cache_file)) rescue {}
|
|
159
|
+
if cache["updateAvailable"]
|
|
160
|
+
update_notice = "Plastic update available: #{cache["current"]} -> #{cache["latest"]} — run /plastic:update"
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
153
164
|
# --- Early exit if nothing to show ---
|
|
154
165
|
|
|
155
166
|
all_active = active + project_active
|
|
156
167
|
all_future = future + project_future
|
|
157
|
-
exit 0 if all_active.empty? && stale.empty? && all_future.empty? && active_deprecations.empty?
|
|
168
|
+
exit 0 if all_active.empty? && stale.empty? && all_future.empty? && active_deprecations.empty? && update_notice.nil?
|
|
158
169
|
|
|
159
170
|
# --- Build context ---
|
|
160
171
|
|
|
@@ -215,6 +226,10 @@ if active_deprecations.any?
|
|
|
215
226
|
end
|
|
216
227
|
end
|
|
217
228
|
|
|
229
|
+
if update_notice
|
|
230
|
+
parts.unshift("! #{update_notice}\n")
|
|
231
|
+
end
|
|
232
|
+
|
|
218
233
|
payload = {
|
|
219
234
|
"hookSpecificOutput" => {
|
|
220
235
|
"hookEventName" => "SessionStart",
|
package/scripts/install.rb
CHANGED
|
@@ -141,13 +141,18 @@ def distribute(mode)
|
|
|
141
141
|
puts " \u{1f4e6} #{mode == :update ? "Updating" : "Installing"} core files to #{PLASTIC_HOME}"
|
|
142
142
|
|
|
143
143
|
FileUtils.mkdir_p(PLASTIC_HOME)
|
|
144
|
-
FileUtils.mkdir_p(File.join(PLASTIC_HOME, "scripts"))
|
|
144
|
+
FileUtils.mkdir_p(File.join(PLASTIC_HOME, "scripts", "lib"))
|
|
145
145
|
|
|
146
146
|
core_files = {
|
|
147
147
|
"PLASTIC.md" => "PLASTIC.md",
|
|
148
148
|
"deprecations.yml" => "deprecations.yml",
|
|
149
149
|
"scripts/folgezettel-id" => "scripts/folgezettel-id",
|
|
150
150
|
"scripts/read-config" => "scripts/read-config",
|
|
151
|
+
"scripts/hook-session-start" => "scripts/hook-session-start",
|
|
152
|
+
"scripts/hook-continue" => "scripts/hook-continue",
|
|
153
|
+
"scripts/hook-future-intent-check" => "scripts/hook-future-intent-check",
|
|
154
|
+
"scripts/hook-gate-check" => "scripts/hook-gate-check",
|
|
155
|
+
"scripts/lib/bridge.rb" => "scripts/lib/bridge.rb",
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
core_files.each do |src, dest|
|
|
@@ -239,7 +244,7 @@ def install_claude(config, force)
|
|
|
239
244
|
|
|
240
245
|
installed = []
|
|
241
246
|
|
|
242
|
-
# Copy hooks
|
|
247
|
+
# Copy hooks, rewriting script paths for the installed location
|
|
243
248
|
hook_source = File.join(PACKAGE_ROOT, "hooks")
|
|
244
249
|
Dir.glob(File.join(hook_source, "*")).each do |f|
|
|
245
250
|
next unless File.file?(f)
|
|
@@ -247,7 +252,9 @@ def install_claude(config, force)
|
|
|
247
252
|
next if %w[hooks.json run-hook].include?(basename)
|
|
248
253
|
dest_name = basename.start_with?("plastic-") ? basename : "plastic-#{basename}"
|
|
249
254
|
dest = File.join(hooks_dir, dest_name)
|
|
250
|
-
|
|
255
|
+
content = File.read(f)
|
|
256
|
+
content = content.gsub('$SCRIPT_DIR/../scripts/', '$HOME/.plastic/scripts/')
|
|
257
|
+
File.write(dest, content)
|
|
251
258
|
FileUtils.chmod(0o755, dest)
|
|
252
259
|
installed << dest
|
|
253
260
|
end
|
|
@@ -358,17 +365,19 @@ def merge_claude_hooks(settings_path)
|
|
|
358
365
|
end
|
|
359
366
|
|
|
360
367
|
def purge_stale_plastic_hooks(hooks)
|
|
361
|
-
|
|
368
|
+
plastic_cmd = ->(cmd) { cmd.to_s.include?("plastic-") }
|
|
369
|
+
|
|
370
|
+
hooks.delete("statusLine")
|
|
362
371
|
|
|
363
372
|
hooks.each do |event, groups|
|
|
364
373
|
next unless groups.is_a?(Array)
|
|
365
374
|
|
|
366
375
|
hooks[event] = groups.map do |group|
|
|
367
376
|
if group.is_a?(Hash) && group["hooks"].is_a?(Array)
|
|
368
|
-
group["hooks"].reject! { |h|
|
|
377
|
+
group["hooks"].reject! { |h| plastic_cmd.call(h["command"]) }
|
|
369
378
|
group unless group["hooks"].empty?
|
|
370
379
|
elsif group.is_a?(Hash) && group["command"]
|
|
371
|
-
|
|
380
|
+
plastic_cmd.call(group["command"]) ? nil : group
|
|
372
381
|
else
|
|
373
382
|
group
|
|
374
383
|
end
|