claude-plugin-viban 1.0.28 → 1.0.30

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.
Files changed (2) hide show
  1. package/bin/viban +105 -6
  2. package/package.json +1 -1
package/bin/viban CHANGED
@@ -36,6 +36,82 @@ check_dependencies() {
36
36
  # Only check dependencies for interactive commands (not help)
37
37
  [[ "$1" != "help" && "$1" != "--help" && "$1" != "-h" ]] && check_dependencies
38
38
 
39
+ # ============================================================
40
+ # Auto-update Check (once per day, cached)
41
+ # ============================================================
42
+ _VIBAN_UPDATE_CACHE="${HOME}/.cache/viban/update-check"
43
+
44
+ auto_update_check() {
45
+ local cache_dir="${HOME}/.cache/viban"
46
+ mkdir -p "$cache_dir"
47
+
48
+ local now=$(date +%s)
49
+ local last_check=0
50
+ local cached_latest=""
51
+
52
+ # Read cache
53
+ if [[ -f "$_VIBAN_UPDATE_CACHE" ]]; then
54
+ last_check=$(sed -n '1p' "$_VIBAN_UPDATE_CACHE" 2>/dev/null)
55
+ cached_latest=$(sed -n '2p' "$_VIBAN_UPDATE_CACHE" 2>/dev/null)
56
+ [[ -z "$last_check" ]] && last_check=0
57
+ fi
58
+
59
+ local current
60
+ current=$(grep '"version"' "$VIBAN_SCRIPT_DIR/package.json" 2>/dev/null | sed 's/.*: *"\([^"]*\)".*/\1/')
61
+ [[ -z "$current" ]] && return
62
+
63
+ # Check npm registry at most once per day (86400 seconds)
64
+ local elapsed=$((now - last_check))
65
+ if (( elapsed > 86400 )); then
66
+ # Background check: fetch latest version and write cache
67
+ {
68
+ local latest
69
+ latest=$(npm show claude-plugin-viban version 2>/dev/null)
70
+ if [[ -n "$latest" ]]; then
71
+ printf '%s\n%s\n' "$now" "$latest" > "$_VIBAN_UPDATE_CACHE"
72
+ fi
73
+ } &!
74
+ # Use cached_latest from previous check for this invocation
75
+ fi
76
+
77
+ # Compare and auto-update if newer version available
78
+ if [[ -n "$cached_latest" && "$cached_latest" != "$current" ]]; then
79
+ # Simple semver comparison: split on dots and compare numerically
80
+ local IFS='.'
81
+ local -a cv=($current) lv=($cached_latest)
82
+ local is_newer=false
83
+ for i in 1 2 3; do
84
+ local c=${cv[$i]:-0} l=${lv[$i]:-0}
85
+ if (( l > c )); then
86
+ is_newer=true
87
+ break
88
+ elif (( l < c )); then
89
+ break
90
+ fi
91
+ done
92
+
93
+ if $is_newer; then
94
+ echo "📦 New version available: $current → $cached_latest"
95
+ echo " Updating..."
96
+ if npm install -g claude-plugin-viban@"$cached_latest" 2>/dev/null; then
97
+ echo " ✓ Updated to $cached_latest"
98
+ # Clear cache so next check is fresh
99
+ rm -f "$_VIBAN_UPDATE_CACHE"
100
+ # Re-exec with the new version
101
+ exec "$0" "$@"
102
+ else
103
+ echo " ✗ Update failed, continuing with $current"
104
+ fi
105
+ fi
106
+ fi
107
+ }
108
+
109
+ # Run auto-update for all commands except help/version/update itself
110
+ case "$1" in
111
+ help|--help|-h|--version|-v|update) ;;
112
+ *) auto_update_check "$@" ;;
113
+ esac
114
+
39
115
  IN_TUI=false
40
116
  cleanup() {
41
117
  printf '\033[?25h\033[0m'
@@ -1138,13 +1214,36 @@ cmd_priority() {
1138
1214
  cmd_add() {
1139
1215
  init_json
1140
1216
  [[ -z "$1" ]] && { echo "Usage: viban add \"title\" [\"description\"] [priority] [type] [attachments...]"; exit 1; }
1141
- local title="$1"
1217
+
1218
+ # Support both positional and named args (--title, --description, --priority, --type)
1219
+ local title="" desc="" priority="P3" issue_type=""
1220
+ local -a attachments=()
1221
+ local positional=()
1222
+
1223
+ while [[ $# -gt 0 ]]; do
1224
+ case "$1" in
1225
+ --title) title="$2"; shift 2 ;;
1226
+ --desc|--description) desc="$2"; shift 2 ;;
1227
+ --priority) priority="$2"; shift 2 ;;
1228
+ --type) issue_type="$2"; shift 2 ;;
1229
+ --attach|--attachments) shift; while [[ $# -gt 0 && "$1" != --* ]]; do attachments+=("$1"); shift; done ;;
1230
+ --*) shift 2 2>/dev/null || shift ;; # skip unknown flags
1231
+ *) positional+=("$1"); shift ;;
1232
+ esac
1233
+ done
1234
+
1235
+ # Fall back to positional args if named args not used
1236
+ [[ -z "$title" ]] && title="${positional[1]:-}"
1237
+ [[ -z "$desc" ]] && desc="${positional[2]:-}"
1238
+ [[ "$priority" == "P3" && -n "${positional[3]:-}" ]] && priority="${positional[3]}"
1239
+ [[ -z "$issue_type" && -n "${positional[4]:-}" ]] && issue_type="${positional[4]}"
1240
+ if [[ ${#attachments[@]} -eq 0 && ${#positional[@]} -gt 4 ]]; then
1241
+ attachments=("${positional[@]:5}")
1242
+ fi
1243
+
1244
+ [[ -z "$title" ]] && { echo "Usage: viban add \"title\" [\"description\"] [priority] [type]"; exit 1; }
1245
+
1142
1246
  local id=$(get_next_id) now=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
1143
- local desc="${2:-}"
1144
- local priority="${3:-P3}"
1145
- local issue_type="${4:-}"
1146
- shift 4 2>/dev/null || shift $#
1147
- local attachments=("$@")
1148
1247
  # Validate priority
1149
1248
  [[ ! "$priority" =~ ^P[0-3]$ ]] && priority="P3"
1150
1249
  # Validate type (bug, feat, chore, refactor)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-plugin-viban",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "Terminal Kanban TUI for AI-human collaborative issue tracking",
5
5
  "main": "bin/viban",
6
6
  "bin": {