@zalom/plastic 1.0.0-alpha.4 → 1.0.0-alpha.5

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/statusline CHANGED
@@ -1,16 +1,56 @@
1
1
  #!/bin/bash
2
- # plastic-hook-version: 1.0.0
3
- # StatusLine hook — shows update available warning
2
+ # plastic-hook-version: 2.0.0
3
+ # StatusLine hook — chains user's original statusline, adds Plastic info
4
4
 
5
- CACHE_FILE="$HOME/.plastic/.cache/update-check.json"
5
+ INPUT=$(cat)
6
+
7
+ # --- Chain original statusline ---
8
+ ORIGINAL_CONFIG="$HOME/.plastic/.cache/original-statusline.json"
9
+ ORIGINAL_OUTPUT=""
10
+ if [ -f "$ORIGINAL_CONFIG" ]; then
11
+ ORIGINAL_CMD=$(grep -o '"command":"[^"]*"' "$ORIGINAL_CONFIG" 2>/dev/null | head -1 | cut -d'"' -f4)
12
+ if [ -z "$ORIGINAL_CMD" ]; then
13
+ ORIGINAL_CMD=$(grep -o '"command": "[^"]*"' "$ORIGINAL_CONFIG" 2>/dev/null | head -1 | sed 's/.*"command": "//;s/".*//')
14
+ fi
15
+ if [ -n "$ORIGINAL_CMD" ] && [ -x "$ORIGINAL_CMD" ]; then
16
+ ORIGINAL_OUTPUT=$(echo "$INPUT" | "$ORIGINAL_CMD" 2>/dev/null)
17
+ fi
18
+ fi
19
+
20
+ # --- Plastic status ---
21
+ PLASTIC_PARTS=""
6
22
 
7
- if [ ! -f "$CACHE_FILE" ]; then
8
- exit 0
23
+ # Active intent from INDEX.md
24
+ INDEX="$HOME/.plastic/INDEX.md"
25
+ if [ -f "$INDEX" ]; then
26
+ ACTIVE=$(sed -n '/^## Active$/,/^## /{/^- \[/p;}' "$INDEX" | head -1)
27
+ if [ -n "$ACTIVE" ]; then
28
+ INTENT=$(echo "$ACTIVE" | sed 's/^- \[\([^]]*\)\].*/\1/')
29
+ PLASTIC_PARTS="plastic: ${INTENT}"
30
+ fi
31
+ fi
32
+
33
+ # Update notification
34
+ CACHE_FILE="$HOME/.plastic/.cache/update-check.json"
35
+ if [ -f "$CACHE_FILE" ]; then
36
+ UPDATE_AVAILABLE=$(grep -o '"updateAvailable":true' "$CACHE_FILE" 2>/dev/null)
37
+ if [ -n "$UPDATE_AVAILABLE" ]; then
38
+ LATEST=$(grep -o '"latest":"[^"]*"' "$CACHE_FILE" 2>/dev/null | head -1 | cut -d'"' -f4)
39
+ CURRENT=$(grep -o '"current":"[^"]*"' "$CACHE_FILE" 2>/dev/null | head -1 | cut -d'"' -f4)
40
+ UPDATE_MSG="plastic update: $CURRENT -> $LATEST"
41
+ if [ -n "$PLASTIC_PARTS" ]; then
42
+ PLASTIC_PARTS="$PLASTIC_PARTS | $UPDATE_MSG"
43
+ else
44
+ PLASTIC_PARTS="$UPDATE_MSG"
45
+ fi
46
+ fi
9
47
  fi
10
48
 
11
- UPDATE_AVAILABLE=$(grep -o '"updateAvailable":true' "$CACHE_FILE" 2>/dev/null)
12
- if [ -n "$UPDATE_AVAILABLE" ]; then
13
- LATEST=$(grep -o '"latest":"[^"]*"' "$CACHE_FILE" | cut -d'"' -f4)
14
- CURRENT=$(grep -o '"current":"[^"]*"' "$CACHE_FILE" | cut -d'"' -f4)
15
- echo "Plastic update: $CURRENT → $LATEST — run /plastic:update"
49
+ # --- Combine output ---
50
+ if [ -n "$ORIGINAL_OUTPUT" ] && [ -n "$PLASTIC_PARTS" ]; then
51
+ echo "$ORIGINAL_OUTPUT | $PLASTIC_PARTS"
52
+ elif [ -n "$ORIGINAL_OUTPUT" ]; then
53
+ echo "$ORIGINAL_OUTPUT"
54
+ elif [ -n "$PLASTIC_PARTS" ]; then
55
+ echo "$PLASTIC_PARTS"
16
56
  fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zalom/plastic",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.5",
4
4
  "description": "Intent-driven idea development system for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -359,6 +359,13 @@ def merge_claude_hooks(settings_path)
359
359
  end
360
360
  end
361
361
 
362
+ existing_status = settings["statusLine"]
363
+ if existing_status && !existing_status.dig("command").to_s.include?("plastic-")
364
+ cache_dir = File.join(PLASTIC_HOME, ".cache")
365
+ FileUtils.mkdir_p(cache_dir)
366
+ File.write(File.join(cache_dir, "original-statusline.json"), JSON.pretty_generate(existing_status))
367
+ end
368
+
362
369
  settings["statusLine"] = { "type" => "command", "command" => "#{hook_dir}/plastic-statusline" }
363
370
 
364
371
  write_json_atomic(settings_path, settings)
@@ -465,7 +472,14 @@ def remove_claude_hooks(settings_path)
465
472
 
466
473
  settings["hooks"].delete_if { |_, v| v.is_a?(Array) && v.empty? }
467
474
  settings.delete("hooks") if settings["hooks"]&.empty?
468
- settings.delete("statusLine") if settings.dig("statusLine", "command").to_s.include?("plastic-")
475
+ if settings.dig("statusLine", "command").to_s.include?("plastic-")
476
+ settings.delete("statusLine")
477
+ original_path = File.join(PLASTIC_HOME, ".cache", "original-statusline.json")
478
+ if File.exist?(original_path)
479
+ original = JSON.parse(File.read(original_path)) rescue nil
480
+ settings["statusLine"] = original if original
481
+ end
482
+ end
469
483
 
470
484
  write_json_atomic(settings_path, settings)
471
485
  end