imgstat 3.0.2 → 3.0.3

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.
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # IDE Detection Script for imgstat
4
+ # Identifies the environment and exports the correct routes for rule generation
5
+
6
+ # 1. Initialize variables
7
+ IDE_NAME="Generic"
8
+ RULE_PATH="AGENTS.md"
9
+ SUPPORTS_IMAGES=false
10
+
11
+ # 2. Check for Cursor specifically (it often sets CURSOR_CLI)
12
+ if [[ "$TERM_PROGRAM" == "cursor" ]] || [[ -n "$CURSOR_CLI" ]]; then
13
+ IDE_NAME="Cursor"
14
+ RULE_PATH=".cursor/rules/"
15
+ SUPPORTS_IMAGES=false
16
+
17
+ # 3. Check for Windsurf
18
+ elif [[ "$TERM_PROGRAM" == "windsurf" ]] || [[ -n "$WINDSURF_CLI" ]]; then
19
+ IDE_NAME="Windsurf"
20
+ RULE_PATH=".windsurf/rules/"
21
+ SUPPORTS_IMAGES=false
22
+
23
+ # 4. Check for VS Code / GitHub Copilot
24
+ elif [[ "$TERM_PROGRAM" == "vscode" ]]; then
25
+ IDE_NAME="VS Code"
26
+ RULE_PATH=".github/copilot-instructions.md"
27
+ SUPPORTS_IMAGES=false
28
+
29
+ # 5. Check for Kiro
30
+ elif [[ -n "$KIRO_SESSION_ID" ]] || [[ "$TERM_PROGRAM" == "kiro" ]]; then
31
+ IDE_NAME="Kiro"
32
+ RULE_PATH=".kiro/steering/"
33
+ SUPPORTS_IMAGES=false
34
+
35
+ # 6. Check for iTerm2 (Good for imgstat image rendering)
36
+ elif [[ "$TERM_PROGRAM" == "iTerm.app" ]] || [[ -n "$ITERM_SESSION_ID" ]]; then
37
+ IDE_NAME="iTerm2"
38
+ RULE_PATH=".agents/rules/"
39
+ SUPPORTS_IMAGES=true
40
+
41
+ # 7. Check for Apple Terminal
42
+ elif [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
43
+ IDE_NAME="Apple Terminal"
44
+ RULE_PATH="AGENTS.md"
45
+ SUPPORTS_IMAGES=false
46
+
47
+ # 8. Windows-specific checks (WSL/Git Bash)
48
+ elif [[ -n "$WSLENV" ]] || [[ "$(uname -r)" == *"microsoft"* ]]; then
49
+ # Check for Cursor on Windows
50
+ if command -v tasklist.exe &> /dev/null && tasklist.exe 2>/dev/null | grep -qi "Cursor.exe"; then
51
+ IDE_NAME="Cursor (Windows)"
52
+ RULE_PATH=".cursor/rules/"
53
+ SUPPORTS_IMAGES=false
54
+ # Check for VS Code on Windows
55
+ elif command -v tasklist.exe &> /dev/null && tasklist.exe 2>/dev/null | grep -qi "Code.exe"; then
56
+ IDE_NAME="VS Code (Windows)"
57
+ RULE_PATH=".github/copilot-instructions.md"
58
+ SUPPORTS_IMAGES=false
59
+ else
60
+ IDE_NAME="WSL ($SHELL)"
61
+ RULE_PATH="AGENTS.md"
62
+ SUPPORTS_IMAGES=false
63
+ fi
64
+
65
+ # 9. Fallback/Standard Check
66
+ else
67
+ IDE_NAME="Generic Shell ($SHELL)"
68
+ RULE_PATH="AGENTS.md"
69
+ fi
70
+
71
+ # Export the results for use in other scripts
72
+ export IMGSTAT_IDE="$IDE_NAME"
73
+ export IMGSTAT_PATH="$RULE_PATH"
74
+ export IMGSTAT_SUPPORTS_IMAGES="$SUPPORTS_IMAGES"
75
+
76
+ # Return values (for sourcing)
77
+ echo "$IDE_NAME|$RULE_PATH|$SUPPORTS_IMAGES"
package/lib/remote.sh CHANGED
@@ -18,10 +18,10 @@ cmd_remote() {
18
18
  trap 'rm -rf "$TEMP_DIR"' EXIT
19
19
 
20
20
  # 1. Fetch direct URL (handles direct images without extensions like Cloudinary)
21
- wget -q --content-disposition -P "$TEMP_DIR" "$url" || true
21
+ wget -q --timeout=10 --tries=2 --content-disposition -P "$TEMP_DIR" "$url" || true
22
22
 
23
23
  # 2. Shallow scrape for linked images (handles HTML pages)
24
- wget -q -nd -r -l 1 -A jpeg,jpg,bmp,gif,png,webp,avif -P "$TEMP_DIR" "$url" || true
24
+ wget -q --timeout=10 --tries=2 -nd -r -l 1 -A jpeg,jpg,bmp,gif,png,webp,avif -P "$TEMP_DIR" "$url" || true
25
25
 
26
26
  local all_files=( "$TEMP_DIR"/* )
27
27
  local found_images=()
package/lib/utils.sh CHANGED
@@ -168,3 +168,29 @@ check_content_type_is_image() {
168
168
  fi
169
169
  return 1
170
170
  }
171
+
172
+ # Detect the current IDE/environment and return detection info
173
+ # Usage: detect_ide
174
+ # Returns: IDE_NAME|RULE_PATH|SUPPORTS_IMAGES
175
+ # Also exports: IMGSTAT_IDE, IMGSTAT_PATH, IMGSTAT_SUPPORTS_IMAGES
176
+ detect_ide() {
177
+ local script_dir
178
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
179
+ source "$script_dir/detect-ide.sh"
180
+ }
181
+
182
+ # Get the IDE-specific rule path for writing output
183
+ # Usage: get_rule_path
184
+ # Returns: The path where rules/context should be written
185
+ get_rule_path() {
186
+ detect_ide > /dev/null
187
+ echo "$IMGSTAT_PATH"
188
+ }
189
+
190
+ # Check if the current environment supports image rendering
191
+ # Usage: supports_image_rendering
192
+ # Returns: 0 (true) if images can be rendered, 1 (false) otherwise
193
+ supports_image_rendering() {
194
+ detect_ide > /dev/null
195
+ [[ "$IMGSTAT_SUPPORTS_IMAGES" == "true" ]]
196
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imgstat",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Embeds image dimensions directly into filenames for natural AI context.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"