CruxExperts/LocalSetup / ls/skills/ls-backblaze-b2-storage
ls-backblaze-b2-storage
VerifiedSafely plan and execute Backblaze B2 S3-compatible storage operations and B2 native bucket, key, and notification administration.
scripts/lib/ls_backblaze/reporting.py
View on GitHub"""Stable JSON envelopes and redaction for the Backblaze CLI."""
from __future__ import annotations
import json
from datetime import date, datetime
from typing import Any
from . import SCHEMA_VERSION
EXIT = {"ok": 0, "input": 2, "policy": 3, "service": 4, "uncertain": 5, "interrupt": 130}
SENSITIVE = {"authorizationtoken", "applicationkey", "secret", "secretaccesskey", "sessiontoken", "password", "hmacsha256signingsecret"}
def scrub(value: Any, key: str = "") -> Any:
normalized = "".join(character for character in key.lower() if character.isalnum())
if normalized in SENSITIVE or normalized == "customheaders":
return "[redacted]"
if isinstance(value, dict):
return {str(k): scrub(v, str(k)) for k, v in value.items()}
if isinstance(value, list):
return [scrub(item) for item in value]
if isinstance(value, (date, datetime)):
return value.isoformat()
return value
def envelope(operation: str, *, outcome: str, result: Any = None, error: dict[str, Any] | None = None) -> dict[str, Any]:
data: dict[str, Any] = {"schema_version": SCHEMA_VERSION, "operation": operation, "ok": outcome in {"planned", "succeeded"}, "outcome": outcome}
if error is not None:
data["error"] = scrub(error)
else:
data["result"] = scrub(result if result is not None else {})
return data
class ToolError(Exception):
def __init__(self, code: str, message: str, exit_name: str = "input", retryable: bool = False, reconciliation: str | None = None):
super().__init__(message)
self.code, self.message, self.exit_name = code, message, exit_name
self.retryable, self.reconciliation = retryable, reconciliation
def as_envelope(self, operation: str) -> dict[str, Any]:
outcome = "unknown" if self.exit_name == "uncertain" else "failed"
error: dict[str, Any] = {"code": self.code, "message": self.message, "retryable": self.retryable}
if hasattr(self, "members"):
error["members"] = self.members
if self.reconciliation:
error["reconciliation"] = self.reconciliation
return envelope(operation, outcome=outcome, error=error)
def emit(data: dict[str, Any]) -> None:
print(json.dumps(data, sort_keys=True, separators=(",", ":"), allow_nan=False))
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |