@trac3er/oh-my-god 2.0.0 → 2.0.2
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.
- package/.claude-plugin/marketplace.json +8 -8
- package/.claude-plugin/plugin.json +5 -4
- package/.claude-plugin/scripts/uninstall.sh +74 -3
- package/.claude-plugin/scripts/update.sh +78 -3
- package/.coveragerc +26 -0
- package/.mcp.json +4 -4
- package/CHANGELOG.md +14 -0
- package/CODE_OF_CONDUCT.md +27 -0
- package/CONTRIBUTING.md +62 -0
- package/OMG-setup.sh +1201 -355
- package/README.md +77 -56
- package/SECURITY.md +25 -0
- package/agents/__init__.py +1 -0
- package/agents/model_roles.py +196 -0
- package/agents/omg-architect-mode.md +3 -5
- package/agents/omg-backend-engineer.md +3 -5
- package/agents/omg-database-engineer.md +3 -5
- package/agents/omg-frontend-designer.md +4 -5
- package/agents/omg-implement-mode.md +4 -5
- package/agents/omg-infra-engineer.md +3 -5
- package/agents/omg-research-mode.md +4 -6
- package/agents/omg-security-auditor.md +3 -5
- package/agents/omg-testing-engineer.md +3 -5
- package/build/lib/yaml.py +321 -0
- package/commands/OMG:ai-commit.md +101 -14
- package/commands/OMG:arch.md +302 -19
- package/commands/OMG:ccg.md +12 -7
- package/commands/OMG:compat.md +25 -17
- package/commands/OMG:cost.md +173 -13
- package/commands/OMG:crazy.md +1 -1
- package/commands/OMG:create-agent.md +170 -20
- package/commands/OMG:deps.md +235 -17
- package/commands/OMG:domain-init.md +1 -1
- package/commands/OMG:escalate.md +41 -12
- package/commands/OMG:health-check.md +37 -13
- package/commands/OMG:init.md +122 -14
- package/commands/OMG:project-init.md +1 -1
- package/commands/OMG:session-branch.md +76 -9
- package/commands/OMG:session-fork.md +42 -5
- package/commands/OMG:session-merge.md +124 -8
- package/commands/OMG:setup.md +69 -12
- package/commands/OMG:stats.md +215 -14
- package/commands/OMG:teams.md +19 -10
- package/config/lsp_languages.yaml +8 -0
- package/hooks/__init__.py +0 -0
- package/hooks/_agent_registry.py +423 -0
- package/hooks/_analytics.py +291 -0
- package/hooks/_budget.py +31 -0
- package/hooks/_common.py +569 -0
- package/hooks/_compression_optimizer.py +119 -0
- package/hooks/_cost_ledger.py +176 -0
- package/hooks/_learnings.py +126 -0
- package/hooks/_memory.py +103 -0
- package/hooks/_protected_context.py +150 -0
- package/hooks/_token_counter.py +221 -0
- package/hooks/branch_manager.py +236 -0
- package/hooks/budget_governor.py +232 -0
- package/hooks/circuit-breaker.py +270 -0
- package/hooks/compression_feedback.py +254 -0
- package/hooks/config-guard.py +216 -0
- package/hooks/context_pressure.py +53 -0
- package/hooks/credential_store.py +1020 -0
- package/hooks/fetch-rate-limits.py +212 -0
- package/hooks/firewall.py +48 -0
- package/hooks/hashline-formatter-bridge.py +224 -0
- package/hooks/hashline-injector.py +273 -0
- package/hooks/hashline-validator.py +216 -0
- package/hooks/idle-detector.py +95 -0
- package/hooks/intentgate-keyword-detector.py +188 -0
- package/hooks/magic-keyword-router.py +195 -0
- package/hooks/policy_engine.py +505 -0
- package/hooks/post-tool-failure.py +19 -0
- package/hooks/post-write.py +219 -0
- package/hooks/post_write.py +46 -0
- package/hooks/pre-compact.py +398 -0
- package/hooks/pre-tool-inject.py +98 -0
- package/hooks/prompt-enhancer.py +672 -0
- package/hooks/quality-runner.py +191 -0
- package/hooks/query.py +512 -0
- package/hooks/secret-guard.py +61 -0
- package/hooks/secret_audit.py +144 -0
- package/hooks/session-end-capture.py +137 -0
- package/hooks/session-start.py +277 -0
- package/hooks/setup_wizard.py +582 -0
- package/hooks/shadow_manager.py +297 -0
- package/hooks/state_migration.py +225 -0
- package/hooks/stop-gate.py +7 -0
- package/hooks/stop_dispatcher.py +945 -0
- package/hooks/test-validator.py +361 -0
- package/hooks/test_generator_hook.py +123 -0
- package/hooks/todo-state-tracker.py +114 -0
- package/hooks/tool-ledger.py +149 -0
- package/hooks/trust_review.py +585 -0
- package/hud/omg-hud.mjs +31 -1
- package/lab/__init__.py +1 -0
- package/lab/pipeline.py +75 -0
- package/lab/policies.py +52 -0
- package/package.json +7 -18
- package/plugins/README.md +33 -61
- package/plugins/advanced/commands/OMG:deep-plan.md +3 -3
- package/plugins/advanced/commands/OMG:learn.md +1 -1
- package/plugins/advanced/commands/OMG:security-review.md +3 -3
- package/plugins/advanced/commands/OMG:ship.md +1 -1
- package/plugins/advanced/plugin.json +1 -1
- package/plugins/core/plugin.json +8 -3
- package/plugins/dephealth/__init__.py +0 -0
- package/plugins/dephealth/cve_scanner.py +188 -0
- package/plugins/dephealth/license_checker.py +135 -0
- package/plugins/dephealth/manifest_detector.py +423 -0
- package/plugins/dephealth/vuln_analyzer.py +169 -0
- package/plugins/testgen/__init__.py +0 -0
- package/plugins/testgen/codamosa_engine.py +402 -0
- package/plugins/testgen/edge_case_synthesizer.py +184 -0
- package/plugins/testgen/framework_detector.py +271 -0
- package/plugins/testgen/skeleton_generator.py +219 -0
- package/plugins/viz/__init__.py +0 -0
- package/plugins/viz/ast_parser.py +139 -0
- package/plugins/viz/diagram_generator.py +192 -0
- package/plugins/viz/graph_builder.py +444 -0
- package/plugins/viz/native_parsers.py +259 -0
- package/plugins/viz/regex_parser.py +112 -0
- package/pyproject.toml +81 -0
- package/rules/contextual/write-verify.md +2 -2
- package/rules/core/00-truth.md +1 -1
- package/rules/core/01-surgical.md +1 -1
- package/rules/core/02-circuit-breaker.md +2 -2
- package/rules/core/03-ensemble.md +3 -3
- package/rules/core/04-testing.md +3 -3
- package/runtime/__init__.py +32 -0
- package/runtime/adapters/__init__.py +13 -0
- package/runtime/adapters/claude.py +60 -0
- package/runtime/adapters/gpt.py +53 -0
- package/runtime/adapters/local.py +53 -0
- package/runtime/adoption.py +212 -0
- package/runtime/business_workflow.py +220 -0
- package/runtime/cli_provider.py +85 -0
- package/runtime/compat.py +1299 -0
- package/runtime/custom_agent_loader.py +366 -0
- package/runtime/dispatcher.py +47 -0
- package/runtime/ecosystem.py +371 -0
- package/runtime/legacy_compat.py +7 -0
- package/runtime/mcp_config_writers.py +115 -0
- package/runtime/mcp_lifecycle.py +153 -0
- package/runtime/mcp_memory_server.py +135 -0
- package/runtime/memory_parsers/__init__.py +0 -0
- package/runtime/memory_parsers/chatgpt_parser.py +257 -0
- package/runtime/memory_parsers/claude_import.py +107 -0
- package/runtime/memory_parsers/export.py +97 -0
- package/runtime/memory_parsers/gemini_import.py +91 -0
- package/runtime/memory_parsers/kimi_import.py +91 -0
- package/runtime/memory_store.py +215 -0
- package/runtime/omc_compat.py +7 -0
- package/runtime/providers/__init__.py +0 -0
- package/runtime/providers/codex_provider.py +112 -0
- package/runtime/providers/gemini_provider.py +128 -0
- package/runtime/providers/kimi_provider.py +151 -0
- package/runtime/providers/opencode_provider.py +144 -0
- package/runtime/subagent_dispatcher.py +362 -0
- package/runtime/team_router.py +1167 -0
- package/runtime/tmux_session_manager.py +169 -0
- package/scripts/check-omg-compat-contract-snapshot.py +137 -0
- package/scripts/check-omg-contract-snapshot.py +12 -0
- package/scripts/check-omg-public-ready.py +193 -0
- package/scripts/check-omg-standalone-clean.py +103 -0
- package/scripts/legacy_to_omg_migrate.py +29 -0
- package/scripts/migrate-legacy.py +464 -0
- package/scripts/omc_to_omg_migrate.py +12 -0
- package/scripts/omg.py +492 -0
- package/scripts/settings-merge.py +283 -0
- package/scripts/verify-standalone.sh +8 -4
- package/settings.json +126 -29
- package/templates/profile.yaml +1 -1
- package/tools/__init__.py +2 -0
- package/tools/browser_consent.py +289 -0
- package/tools/browser_stealth.py +481 -0
- package/tools/browser_tool.py +448 -0
- package/tools/changelog_generator.py +347 -0
- package/tools/commit_splitter.py +746 -0
- package/tools/config_discovery.py +151 -0
- package/tools/config_merger.py +449 -0
- package/tools/dashboard_generator.py +300 -0
- package/tools/git_inspector.py +298 -0
- package/tools/lsp_client.py +275 -0
- package/tools/lsp_discovery.py +231 -0
- package/tools/lsp_operations.py +392 -0
- package/tools/pr_generator.py +404 -0
- package/tools/python_repl.py +656 -0
- package/tools/python_sandbox.py +609 -0
- package/tools/search_providers/__init__.py +77 -0
- package/tools/search_providers/brave.py +115 -0
- package/tools/search_providers/exa.py +116 -0
- package/tools/search_providers/jina.py +104 -0
- package/tools/search_providers/perplexity.py +139 -0
- package/tools/search_providers/synthetic.py +74 -0
- package/tools/session_snapshot.py +736 -0
- package/tools/ssh_manager.py +912 -0
- package/tools/theme_engine.py +294 -0
- package/tools/theme_selector.py +137 -0
- package/tools/web_search.py +622 -0
- package/yaml.py +321 -0
- package/.claude-plugin/scripts/install.sh +0 -9
- package/bun.lock +0 -23
- package/bunfig.toml +0 -3
- package/hooks/_budget.ts +0 -1
- package/hooks/_common.ts +0 -63
- package/hooks/circuit-breaker.ts +0 -101
- package/hooks/config-guard.ts +0 -4
- package/hooks/firewall.ts +0 -20
- package/hooks/policy_engine.ts +0 -156
- package/hooks/post-tool-failure.ts +0 -22
- package/hooks/post-write.ts +0 -4
- package/hooks/pre-tool-inject.ts +0 -4
- package/hooks/prompt-enhancer.ts +0 -46
- package/hooks/quality-runner.ts +0 -24
- package/hooks/secret-guard.ts +0 -4
- package/hooks/session-end-capture.ts +0 -19
- package/hooks/session-start.ts +0 -19
- package/hooks/shadow_manager.ts +0 -81
- package/hooks/stop-gate.ts +0 -22
- package/hooks/stop_dispatcher.ts +0 -147
- package/hooks/test-generator-hook.ts +0 -4
- package/hooks/tool-ledger.ts +0 -27
- package/hooks/trust_review.ts +0 -175
- package/lab/pipeline.ts +0 -75
- package/lab/policies.ts +0 -68
- package/runtime/common.ts +0 -111
- package/runtime/compat.ts +0 -174
- package/runtime/dispatcher.ts +0 -25
- package/runtime/ecosystem.ts +0 -186
- package/runtime/provider_bootstrap.ts +0 -99
- package/runtime/provider_smoke.ts +0 -34
- package/runtime/release_readiness.ts +0 -186
- package/runtime/team_router.ts +0 -144
- package/scripts/check-omg-compat-contract-snapshot.ts +0 -20
- package/scripts/check-omg-standalone-clean.ts +0 -12
- package/scripts/check-runtime-clean.ts +0 -94
- package/scripts/omg.ts +0 -352
- package/scripts/settings-merge.ts +0 -93
- package/tools/commit_splitter.ts +0 -23
- package/tools/git_inspector.ts +0 -18
- package/tools/session_snapshot.ts +0 -47
- package/trac3er-oh-my-god-2.0.0.tgz +0 -0
- package/tsconfig.json +0 -15
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
PostToolUse Hook (*): Tool Execution Ledger (Enterprise)
|
|
4
|
+
Logs every tool execution to .omg/state/ledger/tool-ledger.jsonl.
|
|
5
|
+
Evidence trail for stop-gate.py and claim verification.
|
|
6
|
+
Includes log rotation to prevent unbounded growth.
|
|
7
|
+
"""
|
|
8
|
+
import json, sys, os, re, shutil, time
|
|
9
|
+
from datetime import datetime, timezone
|
|
10
|
+
|
|
11
|
+
HOOKS_DIR = os.path.dirname(__file__)
|
|
12
|
+
if HOOKS_DIR not in sys.path:
|
|
13
|
+
sys.path.insert(0, HOOKS_DIR)
|
|
14
|
+
|
|
15
|
+
from _common import setup_crash_handler, json_input, get_project_dir
|
|
16
|
+
from state_migration import resolve_state_dir
|
|
17
|
+
|
|
18
|
+
setup_crash_handler("tool-ledger", fail_closed=False)
|
|
19
|
+
|
|
20
|
+
data = json_input()
|
|
21
|
+
_wall_start = time.monotonic()
|
|
22
|
+
|
|
23
|
+
project_dir = get_project_dir()
|
|
24
|
+
ledger_dir = resolve_state_dir(project_dir, "state/ledger", "ledger")
|
|
25
|
+
os.makedirs(ledger_dir, exist_ok=True)
|
|
26
|
+
|
|
27
|
+
ledger_path = os.path.join(ledger_dir, "tool-ledger.jsonl")
|
|
28
|
+
|
|
29
|
+
# ── Log rotation: size-only heuristic (avoids O(n) line-count scan) ──
|
|
30
|
+
MAX_BYTES = 5 * 1024 * 1024 # 5MB
|
|
31
|
+
try:
|
|
32
|
+
if os.path.exists(ledger_path):
|
|
33
|
+
size = os.path.getsize(ledger_path)
|
|
34
|
+
needs_rotation = size > MAX_BYTES
|
|
35
|
+
|
|
36
|
+
if needs_rotation:
|
|
37
|
+
archive = ledger_path + ".1"
|
|
38
|
+
# Keep only one archive
|
|
39
|
+
if os.path.exists(archive):
|
|
40
|
+
try:
|
|
41
|
+
os.remove(archive)
|
|
42
|
+
except OSError:
|
|
43
|
+
pass
|
|
44
|
+
shutil.move(ledger_path, archive)
|
|
45
|
+
except Exception:
|
|
46
|
+
pass
|
|
47
|
+
|
|
48
|
+
tool_name = data.get("tool_name", "")
|
|
49
|
+
tool_input = data.get("tool_input", {})
|
|
50
|
+
tool_response = data.get("tool_response", {})
|
|
51
|
+
|
|
52
|
+
entry = {
|
|
53
|
+
"ts": datetime.now(timezone.utc).isoformat(),
|
|
54
|
+
"pid": os.getpid(),
|
|
55
|
+
"tool": tool_name,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# Link ledger entries to OMG v1 run/evidence artifacts when available.
|
|
59
|
+
run_id = os.environ.get("OMG_RUN_ID")
|
|
60
|
+
if not run_id:
|
|
61
|
+
active_run = os.path.join(project_dir, ".omg", "shadow", "active-run")
|
|
62
|
+
if os.path.exists(active_run):
|
|
63
|
+
try:
|
|
64
|
+
with open(active_run, "r", encoding="utf-8") as f:
|
|
65
|
+
run_id = f.read().strip()
|
|
66
|
+
except Exception:
|
|
67
|
+
run_id = None
|
|
68
|
+
if run_id:
|
|
69
|
+
entry["run_id"] = run_id
|
|
70
|
+
|
|
71
|
+
if tool_name == "Bash":
|
|
72
|
+
entry["command"] = tool_input.get("command", "")[:500]
|
|
73
|
+
if isinstance(tool_response, dict):
|
|
74
|
+
entry["exit_code"] = tool_response.get("exitCode", tool_response.get("exit_code"))
|
|
75
|
+
snippet = str(tool_response.get("stdout", ""))[:200]
|
|
76
|
+
# Mask potential secrets in stdout before logging
|
|
77
|
+
# Aligned with post-write.py SECRET_PATTERNS for consistent coverage
|
|
78
|
+
SECRET_PATTERNS = [
|
|
79
|
+
(r'(?i)(api[_-]?key|token|secret|password|passwd|credential|auth)[=:]\s*\S+', r'\1=***'),
|
|
80
|
+
(r'AKIA[0-9A-Z]{16}', '***AWS_KEY***'),
|
|
81
|
+
(r'(?:aws_secret_access_key|AWS_SECRET)\s*[:=]\s*[\'"]?[A-Za-z0-9/+=]{40}', '***AWS_SECRET***'),
|
|
82
|
+
(r'-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----', '***PRIVATE_KEY***'),
|
|
83
|
+
(r'sk-[a-zA-Z0-9]{20,}', '***API_KEY***'),
|
|
84
|
+
(r'gh[ps]_[A-Za-z0-9_]{36,}', '***GH_TOKEN***'),
|
|
85
|
+
(r'github_pat_[A-Za-z0-9_]{22,}', '***GH_PAT***'),
|
|
86
|
+
(r'xox[bp]-[0-9]{10,}-[A-Za-z0-9]{20,}', '***SLACK_TOKEN***'),
|
|
87
|
+
(r'sk_live_[A-Za-z0-9]{20,}', '***STRIPE_KEY***'),
|
|
88
|
+
(r'rk_live_[A-Za-z0-9]{20,}', '***STRIPE_KEY***'),
|
|
89
|
+
(r'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\.[A-Za-z0-9_-]{20,}', '***SERVICE_KEY***'),
|
|
90
|
+
(r'AIza[A-Za-z0-9_-]{35}', '***GOOGLE_KEY***'),
|
|
91
|
+
(r'SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}', '***SENDGRID_KEY***'),
|
|
92
|
+
(r'eyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}', '***JWT***'),
|
|
93
|
+
(r'(?:postgres|mysql|mongodb|redis)://[^:]+:[^@]+@', '***DB_URL***'),
|
|
94
|
+
(r'https?://[^:]+:[^@]+@', '***URL_CREDS***'),
|
|
95
|
+
]
|
|
96
|
+
for pattern, replacement in SECRET_PATTERNS:
|
|
97
|
+
snippet = re.sub(pattern, replacement, snippet)
|
|
98
|
+
entry["stdout_snippet"] = snippet
|
|
99
|
+
elif tool_name in ("Write", "Edit", "MultiEdit"):
|
|
100
|
+
entry["file"] = tool_input.get("file_path", "")
|
|
101
|
+
entry["success"] = tool_response.get("success") if isinstance(tool_response, dict) else None
|
|
102
|
+
elif tool_name == "Read":
|
|
103
|
+
entry["file"] = tool_input.get("file_path", "")
|
|
104
|
+
|
|
105
|
+
# Attach the latest evidence file path if one exists for this run.
|
|
106
|
+
if run_id:
|
|
107
|
+
ev_path = os.path.join(project_dir, ".omg", "evidence", f"{run_id}.json")
|
|
108
|
+
if os.path.exists(ev_path):
|
|
109
|
+
entry["evidence_path"] = os.path.relpath(ev_path, project_dir)
|
|
110
|
+
|
|
111
|
+
# ── Latency tracking: duration_ms ──
|
|
112
|
+
# Prefer startTime/endTime from hook stdin (ISO8601), fall back to wall clock.
|
|
113
|
+
_duration_ms = None
|
|
114
|
+
try:
|
|
115
|
+
_start_str = data.get("startTime")
|
|
116
|
+
_end_str = data.get("endTime")
|
|
117
|
+
if _start_str and _end_str:
|
|
118
|
+
_st = datetime.fromisoformat(_start_str.replace("Z", "+00:00"))
|
|
119
|
+
_et = datetime.fromisoformat(_end_str.replace("Z", "+00:00"))
|
|
120
|
+
_duration_ms = int((_et - _st).total_seconds() * 1000)
|
|
121
|
+
else:
|
|
122
|
+
# Wall clock fallback
|
|
123
|
+
_duration_ms = int((time.monotonic() - _wall_start) * 1000)
|
|
124
|
+
except Exception:
|
|
125
|
+
# Malformed timestamps: fall back to wall clock, or null if that also fails
|
|
126
|
+
try:
|
|
127
|
+
_duration_ms = int((time.monotonic() - _wall_start) * 1000)
|
|
128
|
+
except Exception:
|
|
129
|
+
_duration_ms = None
|
|
130
|
+
|
|
131
|
+
entry["duration_ms"] = _duration_ms
|
|
132
|
+
|
|
133
|
+
try:
|
|
134
|
+
import fcntl
|
|
135
|
+
fd = open(ledger_path, "a")
|
|
136
|
+
fcntl.flock(fd.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
137
|
+
fd.write(json.dumps(entry, separators=(",", ":")) + "\n")
|
|
138
|
+
fcntl.flock(fd.fileno(), fcntl.LOCK_UN)
|
|
139
|
+
fd.close()
|
|
140
|
+
except (ImportError, BlockingIOError):
|
|
141
|
+
try:
|
|
142
|
+
with open(ledger_path, "a") as f:
|
|
143
|
+
f.write(json.dumps(entry, separators=(",", ":")) + "\n")
|
|
144
|
+
except Exception:
|
|
145
|
+
pass
|
|
146
|
+
except Exception:
|
|
147
|
+
pass # Non-blocking: don't fail the tool call
|
|
148
|
+
|
|
149
|
+
sys.exit(0)
|