@torka/claude-workflows 0.1.0 → 0.2.0

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.
@@ -1,134 +0,0 @@
1
- {
2
- "allow_patterns": [
3
- "^pwd$",
4
- "^whoami$",
5
- "^date$",
6
- "^uname(\\s+-a)?$",
7
- "^which\\s+\\S+$",
8
- "^echo\\s+",
9
-
10
- "^ls(\\s+.*)?$",
11
- "^cat\\s+",
12
- "^head\\s+",
13
- "^tail\\s+",
14
- "^wc\\s+",
15
- "^less\\s+",
16
- "^file\\s+",
17
- "^stat\\s+",
18
- "^du\\s+",
19
- "^df\\s+",
20
- "^tree(\\s+.*)?$",
21
-
22
- "^python(3)?\\s+--version$",
23
- "^node\\s+--version$",
24
- "^npm\\s+--version$",
25
- "^pnpm\\s+--version$",
26
- "^yarn\\s+--version$",
27
- "^uv\\s+--version$",
28
-
29
- "^git\\s+(status|diff|log|show|branch|remote|stash\\s+list)(\\s+.*)?$",
30
-
31
- "^pnpm\\s+(test|run\\s+(test|lint|typecheck|type-check|check|build|dev|start)|install|i|add|remove)(\\s+.*)?$",
32
- "^npm\\s+(test|run\\s+(test|lint|typecheck|type-check|check|build|dev|start)|install|i|ci)(\\s+.*)?$",
33
- "^yarn\\s+(test|lint|typecheck|type-check|check|build|dev|start|install|add|remove)(\\s+.*)?$",
34
- "^npx\\s+(tsc|eslint|prettier|vitest|jest)(\\s+.*)?$",
35
-
36
- "^pytest(\\s+.*)?$",
37
- "^python(3)?\\s+-m\\s+pytest(\\s+.*)?$",
38
- "^uv\\s+run\\s+(pytest|python|ruff|mypy)(\\s+.*)?$",
39
- "^ruff\\s+(check|format)(\\s+.*)?$",
40
- "^mypy(\\s+.*)?$",
41
- "^black\\s+--check(\\s+.*)?$",
42
- "^isort\\s+--check(\\s+.*)?$",
43
- "^pip\\s+(list|show|freeze)$",
44
- "^uv\\s+(pip\\s+list|pip\\s+show|sync|lock)(\\s+.*)?$",
45
-
46
- "^cargo\\s+(check|test|clippy|fmt\\s+--check|build)(\\s+.*)?$",
47
- "^go\\s+(test|vet|fmt|build)(\\s+.*)?$",
48
-
49
- "^jq\\s+",
50
- "^grep\\s+",
51
- "^rg\\s+",
52
- "^find\\s+",
53
- "^fd\\s+",
54
- "^ag\\s+",
55
- "^awk\\s+",
56
- "^sed\\s+-n\\s+",
57
- "^sort(\\s+.*)?$",
58
- "^uniq(\\s+.*)?$",
59
- "^cut\\s+",
60
- "^tr\\s+",
61
- "^diff\\s+",
62
- "^comm\\s+",
63
-
64
- "^curl\\s+.*--head",
65
- "^curl\\s+-I\\s+",
66
- "^ping\\s+-c\\s+\\d+\\s+",
67
- "^dig\\s+",
68
- "^nslookup\\s+",
69
- "^host\\s+",
70
-
71
- "^mkdir(\\s+.*)?$",
72
- "^touch\\s+",
73
- "^cp\\s+",
74
- "^mv\\s+",
75
-
76
- "^git\\s+(add|commit|checkout|fetch|pull|push|worktree|merge|rebase|stash\\s+(push|pop|drop|apply)|tag|switch|restore)(\\s+.*)?$",
77
-
78
- "^gh\\s+(pr|issue|repo|release|workflow|run|api)(\\s+.*)?$",
79
-
80
- "^chmod\\s+[0-6][0-7][0-7]\\s+"
81
- ],
82
-
83
- "deny_patterns": [
84
- "^sudo\\b",
85
- "^doas\\b",
86
- "\\brm\\s+.*(-r|-rf|-fr|--recursive)",
87
- "\\brm\\s+-[^\\s]*r",
88
- "^rm\\s+/",
89
- "\\bmkfs\\.",
90
- "\\bdd\\b.*\\bof=",
91
- "\\bshutdown\\b",
92
- "\\breboot\\b",
93
- "\\bsystemctl\\s+(start|stop|restart|enable|disable)",
94
- "\\bchmod\\s+777",
95
- "\\bchown\\s+.*:.*\\s+/",
96
- ">\\s*/etc/",
97
- ">\\s*~/\\.",
98
- "\\bcurl\\b.*\\|.*\\b(bash|sh|zsh)\\b",
99
- "\\bwget\\b.*\\|.*\\b(bash|sh|zsh)\\b",
100
- "\\beval\\s+.*\\$\\(",
101
- ":(){ :|:& };:",
102
- "\\bfork\\s*bomb",
103
- "\\bkill\\s+-9\\s+-1",
104
- "\\bpkill\\s+-9",
105
- "\\bkillall\\b"
106
- ],
107
-
108
- "sensitive_paths": [
109
- "\\.env$",
110
- "\\.env\\.",
111
- "\\.pem$",
112
- "\\.key$",
113
- "\\.crt$",
114
- "\\.p12$",
115
- "\\.pfx$",
116
- "id_rsa",
117
- "id_ed25519",
118
- "id_ecdsa",
119
- "\\.ssh/",
120
- "\\.gnupg/",
121
- "\\.git/config$",
122
- "\\.gitconfig$",
123
- "credentials",
124
- "\\.aws/",
125
- "\\.gcloud/",
126
- "\\.azure/",
127
- "\\.npmrc$",
128
- "\\.pypirc$",
129
- "\\.netrc$",
130
- "\\bsecrets?\\b",
131
- "\\bpassw",
132
- "\\btoken"
133
- ]
134
- }
@@ -1,175 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Claude Code Context Monitor
4
- Real-time context usage monitoring with visual indicators and session analytics
5
- https://code.claude.com/docs/en/statusline
6
- """
7
-
8
- import json
9
- import sys
10
- import os
11
-
12
-
13
- def context_window_info(window):
14
- """
15
- Build context info from the statusline `context_window` payload.
16
- Expected shape:
17
- {
18
- "context_window_size": int,
19
- "current_usage": {
20
- "input_tokens": int,
21
- "output_tokens": int,
22
- "cache_creation_input_tokens": int,
23
- "cache_read_input_tokens": int
24
- }
25
- }
26
- """
27
- if not isinstance(window, dict):
28
- return None
29
-
30
- size = window.get("context_window_size")
31
- if not size or size <= 0:
32
- return None
33
-
34
- usage = window.get("current_usage")
35
-
36
- # If no calls yet, usage may be null; treat as 0% used.
37
- if usage is None:
38
- return {
39
- "percent": 0,
40
- "tokens": 0,
41
- "method": "context_window",
42
- }
43
-
44
- if not isinstance(usage, dict):
45
- return None
46
-
47
- tokens = (
48
- usage.get("input_tokens", 0)
49
- + usage.get("output_tokens", 0)
50
- + usage.get("cache_creation_input_tokens", 0)
51
- + usage.get("cache_read_input_tokens", 0)
52
- )
53
-
54
- percent = (tokens / size) * 100 if size > 0 else 0
55
-
56
- return {
57
- "percent": max(0, min(100, percent)),
58
- "tokens": tokens,
59
- "method": "context_window",
60
- }
61
-
62
-
63
- def get_context_display(context_info):
64
- """Generate context display with visual indicators."""
65
- if not context_info:
66
- return "🔵 ???"
67
-
68
- percent = context_info.get('percent', 0)
69
- percent = max(0, min(100, percent))
70
- warning = context_info.get('warning')
71
-
72
- # Color based on usage level
73
- if percent >= 95:
74
- color = "\033[31;1m" # Blinking red
75
- alert = "CRIT"
76
- elif percent >= 90:
77
- color = "\033[31m" # Red
78
- alert = "HIGH"
79
- elif percent >= 75:
80
- color = "\033[91m" # Light red
81
- alert = ""
82
- elif percent >= 50:
83
- color = "\033[33m" # Yellow
84
- alert = ""
85
- else:
86
- color = "\033[32m" # Green
87
- alert = ""
88
-
89
- # Create progress bar
90
- segments = 8
91
- filled = int((percent / 100) * segments)
92
- bar = "█" * filled + "▁" * (segments - filled)
93
-
94
- # Special warnings
95
- if warning == 'auto-compact':
96
- alert = "AUTO-COMPACT!"
97
- elif warning == 'low':
98
- alert = "LOW!"
99
-
100
- reset = "\033[0m"
101
- alert_str = f" {alert}" if alert else ""
102
-
103
- return f"{color}{bar}{reset} {percent:.0f}%{alert_str}"
104
-
105
- def get_directory_display(workspace_data):
106
- """Get directory display name."""
107
- current_dir = workspace_data.get('current_dir', '')
108
- project_dir = workspace_data.get('project_dir', '')
109
- cwd = workspace_data.get('cwd', '')
110
-
111
- if current_dir and project_dir:
112
- if current_dir.startswith(project_dir):
113
- rel_path = current_dir[len(project_dir):].lstrip('/')
114
- return rel_path or os.path.basename(project_dir)
115
- else:
116
- return os.path.basename(current_dir)
117
- elif project_dir:
118
- return os.path.basename(project_dir)
119
- elif cwd:
120
- return os.path.basename(cwd)
121
- elif current_dir:
122
- return os.path.basename(current_dir)
123
- else:
124
- return "unknown"
125
-
126
- def get_git_branch():
127
- """Get the current git branch name by reading .git/HEAD directly."""
128
- try:
129
- git_dir = ".git"
130
- if os.path.isdir(git_dir):
131
- head_file = os.path.join(git_dir, "HEAD")
132
- if os.path.isfile(head_file):
133
- with open(head_file, 'r') as f:
134
- ref = f.read().strip()
135
- if ref.startswith('ref: refs/heads/'):
136
- return ref.replace('ref: refs/heads/', '')
137
- # Detached HEAD state
138
- return ref[:8]
139
- return None
140
- except Exception:
141
- return None
142
-
143
- def main():
144
- try:
145
- # Read JSON input from Claude Code
146
- data = json.load(sys.stdin)
147
-
148
- # Extract information
149
- model_data = data.get('model', {})
150
- model_name = model_data.get('display_name') or model_data.get('name') or model_data.get('id') or 'Claude'
151
- model_id = model_data.get('id') or model_data.get('name') or model_name
152
-
153
- workspace = data.get('workspace', {})
154
- context_window = data.get('context_window') or {}
155
-
156
- # Build status components
157
- context_info = context_window_info(context_window)
158
- context_display = get_context_display(context_info)
159
- directory = get_directory_display(workspace)
160
- git_branch = get_git_branch()
161
- git_display = f" \033[96m🌿 {git_branch}\033[0m" if git_branch else ""
162
-
163
- model_display = f"\033[94m[{model_name}]\033[0m"
164
-
165
- # Combine all components
166
- status_line = f"{model_display} \033[93m📁 {directory}\033[0m{git_display} 🧠 {context_display}"
167
-
168
- print(status_line)
169
-
170
- except Exception as e:
171
- # Fallback display on any error
172
- print(f"\033[94m[Claude]\033[0m \033[93m📁 {os.path.basename(os.getcwd())}\033[0m 🧠 \033[31m[Error: {str(e)[:20]}]\033[0m")
173
-
174
- if __name__ == "__main__":
175
- main()