tweek 0.4.0__py3-none-any.whl → 0.4.2__py3-none-any.whl
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.
- tweek/__init__.py +1 -1
- tweek/cli_core.py +23 -6
- tweek/cli_install.py +361 -91
- tweek/cli_uninstall.py +119 -36
- tweek/config/families.yaml +13 -0
- tweek/config/models.py +31 -3
- tweek/config/patterns.yaml +126 -2
- tweek/diagnostics.py +124 -1
- tweek/hooks/break_glass.py +70 -47
- tweek/hooks/overrides.py +19 -1
- tweek/hooks/post_tool_use.py +6 -2
- tweek/hooks/pre_tool_use.py +19 -2
- tweek/hooks/wrapper_post_tool_use.py +121 -0
- tweek/hooks/wrapper_pre_tool_use.py +121 -0
- tweek/integrations/openclaw.py +70 -60
- tweek/integrations/openclaw_detection.py +140 -0
- tweek/integrations/openclaw_server.py +359 -86
- tweek/logging/security_log.py +22 -0
- tweek/memory/safety.py +7 -3
- tweek/memory/store.py +31 -10
- tweek/plugins/base.py +9 -1
- tweek/plugins/detectors/openclaw.py +31 -92
- tweek/plugins/screening/heuristic_scorer.py +12 -1
- tweek/plugins/screening/local_model_reviewer.py +9 -0
- tweek/security/language.py +2 -1
- tweek/security/llm_reviewer.py +53 -24
- tweek/security/local_model.py +21 -0
- tweek/security/model_registry.py +2 -2
- tweek/security/rate_limiter.py +99 -1
- tweek/skills/guard.py +30 -7
- {tweek-0.4.0.dist-info → tweek-0.4.2.dist-info}/METADATA +1 -1
- {tweek-0.4.0.dist-info → tweek-0.4.2.dist-info}/RECORD +37 -34
- {tweek-0.4.0.dist-info → tweek-0.4.2.dist-info}/WHEEL +0 -0
- {tweek-0.4.0.dist-info → tweek-0.4.2.dist-info}/entry_points.txt +0 -0
- {tweek-0.4.0.dist-info → tweek-0.4.2.dist-info}/licenses/LICENSE +0 -0
- {tweek-0.4.0.dist-info → tweek-0.4.2.dist-info}/licenses/NOTICE +0 -0
- {tweek-0.4.0.dist-info → tweek-0.4.2.dist-info}/top_level.txt +0 -0
tweek/__init__.py
CHANGED
tweek/cli_core.py
CHANGED
|
@@ -279,6 +279,9 @@ def update(check: bool):
|
|
|
279
279
|
"""
|
|
280
280
|
import subprocess
|
|
281
281
|
|
|
282
|
+
# Timeout for git operations (seconds) — prevents hanging on network issues
|
|
283
|
+
GIT_TIMEOUT = 30
|
|
284
|
+
|
|
282
285
|
patterns_dir = Path("~/.tweek/patterns").expanduser()
|
|
283
286
|
patterns_repo = "https://github.com/gettweek/tweek.git"
|
|
284
287
|
|
|
@@ -298,7 +301,8 @@ def update(check: bool):
|
|
|
298
301
|
["git", "clone", "--depth", "1", patterns_repo, str(patterns_dir)],
|
|
299
302
|
capture_output=True,
|
|
300
303
|
text=True,
|
|
301
|
-
check=True
|
|
304
|
+
check=True,
|
|
305
|
+
timeout=GIT_TIMEOUT,
|
|
302
306
|
)
|
|
303
307
|
console.print("[green]✓[/green] Patterns installed successfully")
|
|
304
308
|
|
|
@@ -312,6 +316,9 @@ def update(check: bool):
|
|
|
312
316
|
free_max = data.get("free_tier_max", 23)
|
|
313
317
|
console.print(f"[white]Installed {count} patterns ({free_max} free, {count - free_max} pro)[/white]")
|
|
314
318
|
|
|
319
|
+
except subprocess.TimeoutExpired:
|
|
320
|
+
console.print(f"[red]✗[/red] Git clone timed out after {GIT_TIMEOUT}s")
|
|
321
|
+
return
|
|
315
322
|
except subprocess.CalledProcessError as e:
|
|
316
323
|
console.print(f"[red]✗[/red] Failed to clone patterns: {e.stderr}")
|
|
317
324
|
return
|
|
@@ -329,13 +336,15 @@ def update(check: bool):
|
|
|
329
336
|
result = subprocess.run(
|
|
330
337
|
["git", "-C", str(patterns_dir), "fetch", "--dry-run"],
|
|
331
338
|
capture_output=True,
|
|
332
|
-
text=True
|
|
339
|
+
text=True,
|
|
340
|
+
timeout=GIT_TIMEOUT,
|
|
333
341
|
)
|
|
334
342
|
# Check if there are updates
|
|
335
343
|
result2 = subprocess.run(
|
|
336
344
|
["git", "-C", str(patterns_dir), "status", "-uno"],
|
|
337
345
|
capture_output=True,
|
|
338
|
-
text=True
|
|
346
|
+
text=True,
|
|
347
|
+
timeout=GIT_TIMEOUT,
|
|
339
348
|
)
|
|
340
349
|
if "behind" in result2.stdout:
|
|
341
350
|
console.print("[yellow]Updates available.[/yellow]")
|
|
@@ -353,7 +362,8 @@ def update(check: bool):
|
|
|
353
362
|
["git", "-C", str(patterns_dir), "pull", "--ff-only"],
|
|
354
363
|
capture_output=True,
|
|
355
364
|
text=True,
|
|
356
|
-
check=True
|
|
365
|
+
check=True,
|
|
366
|
+
timeout=GIT_TIMEOUT,
|
|
357
367
|
)
|
|
358
368
|
|
|
359
369
|
if "Already up to date" in result.stdout:
|
|
@@ -365,6 +375,9 @@ def update(check: bool):
|
|
|
365
375
|
if result.stdout.strip():
|
|
366
376
|
console.print(f"[white]{result.stdout.strip()}[/white]")
|
|
367
377
|
|
|
378
|
+
except subprocess.TimeoutExpired:
|
|
379
|
+
console.print(f"[red]✗[/red] Git pull timed out after {GIT_TIMEOUT}s")
|
|
380
|
+
return
|
|
368
381
|
except subprocess.CalledProcessError as e:
|
|
369
382
|
console.print(f"[red]✗[/red] Failed to update patterns: {e.stderr}")
|
|
370
383
|
console.print("[white]Try: rm -rf ~/.tweek/patterns && tweek update[/white]")
|
|
@@ -400,21 +413,25 @@ def update(check: bool):
|
|
|
400
413
|
Examples:
|
|
401
414
|
tweek doctor Run all health checks
|
|
402
415
|
tweek doctor --verbose Show detailed check information
|
|
416
|
+
tweek doctor --fix Offer to fix issues interactively
|
|
403
417
|
tweek doctor --json Output results as JSON for scripting
|
|
404
418
|
"""
|
|
405
419
|
)
|
|
406
420
|
@click.option("--verbose", "-v", is_flag=True, help="Show detailed check information")
|
|
421
|
+
@click.option("--fix", is_flag=True, help="Offer to fix issues interactively")
|
|
407
422
|
@click.option("--json-output", "--json", "json_out", is_flag=True, help="Output results as JSON")
|
|
408
|
-
def doctor(verbose: bool, json_out: bool):
|
|
423
|
+
def doctor(verbose: bool, fix: bool, json_out: bool):
|
|
409
424
|
"""Run health checks on your Tweek installation.
|
|
410
425
|
|
|
411
426
|
Checks hooks, configuration, patterns, database, vault, sandbox,
|
|
412
427
|
license, MCP, proxy, and plugin integrity.
|
|
428
|
+
|
|
429
|
+
Use --fix to interactively resolve warnings and errors.
|
|
413
430
|
"""
|
|
414
431
|
from tweek.diagnostics import run_health_checks
|
|
415
432
|
from tweek.cli_helpers import print_doctor_results, print_doctor_json
|
|
416
433
|
|
|
417
|
-
checks = run_health_checks(verbose=verbose)
|
|
434
|
+
checks = run_health_checks(verbose=verbose, interactive=fix)
|
|
418
435
|
|
|
419
436
|
if json_out:
|
|
420
437
|
print_doctor_json(checks)
|