conduct-cli 0.4.5__tar.gz → 0.4.6__tar.gz
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.
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/PKG-INFO +1 -1
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/pyproject.toml +1 -1
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli/guard.py +34 -9
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli.egg-info/PKG-INFO +1 -1
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/README.md +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/setup.cfg +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/setup.py +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli/__init__.py +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli/api.py +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli/guardmcp.py +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli/main.py +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli.egg-info/SOURCES.txt +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli.egg-info/dependency_links.txt +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli.egg-info/entry_points.txt +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli.egg-info/requires.txt +0 -0
- {conduct_cli-0.4.5 → conduct_cli-0.4.6}/src/conduct_cli.egg-info/top_level.txt +0 -0
|
@@ -246,7 +246,10 @@ def main():
|
|
|
246
246
|
|
|
247
247
|
|
|
248
248
|
if __name__ == "__main__":
|
|
249
|
-
|
|
249
|
+
if len(sys.argv) > 1 and sys.argv[1] == "post":
|
|
250
|
+
post_usage_main()
|
|
251
|
+
else:
|
|
252
|
+
main()
|
|
250
253
|
'''
|
|
251
254
|
|
|
252
255
|
# ── Guard config helpers ──────────────────────────────────────────────────────
|
|
@@ -343,16 +346,27 @@ def _install_codex_hook(hook_path: Path) -> None:
|
|
|
343
346
|
pre.append({"matcher": ".*", "hooks": [{"type": "command", "command": pre_cmd}]})
|
|
344
347
|
changed = True
|
|
345
348
|
|
|
346
|
-
# PostToolUse
|
|
347
|
-
post_cmd = "
|
|
349
|
+
# PostToolUse — self-contained: python3 /path/hook.py post (no PATH dependency)
|
|
350
|
+
post_cmd = f"python3 {hook_path} post"
|
|
348
351
|
post = hook_section.setdefault("PostToolUse", [])
|
|
352
|
+
# Remove stale conductguard-post entries registered by older CLI versions
|
|
353
|
+
stale = "conductguard-post"
|
|
354
|
+
cleaned = False
|
|
355
|
+
for h in post:
|
|
356
|
+
before = len(h.get("hooks", []))
|
|
357
|
+
h["hooks"] = [e for e in h.get("hooks", []) if e.get("command") != stale]
|
|
358
|
+
if len(h["hooks"]) < before:
|
|
359
|
+
cleaned = True
|
|
360
|
+
post[:] = [h for h in post if h.get("hooks")]
|
|
349
361
|
post_already = any(
|
|
350
362
|
e.get("command") == post_cmd
|
|
351
363
|
for h in post
|
|
352
364
|
for e in h.get("hooks", [])
|
|
353
365
|
)
|
|
354
366
|
if not post_already:
|
|
355
|
-
post.append({"matcher": "
|
|
367
|
+
post.append({"matcher": ".*", "hooks": [{"type": "command", "command": post_cmd}]})
|
|
368
|
+
changed = True
|
|
369
|
+
if cleaned:
|
|
356
370
|
changed = True
|
|
357
371
|
|
|
358
372
|
if changed:
|
|
@@ -360,7 +374,7 @@ def _install_codex_hook(hook_path: Path) -> None:
|
|
|
360
374
|
codex_hooks.write_text(json.dumps(hooks, indent=2))
|
|
361
375
|
if not pre_already:
|
|
362
376
|
print(f" {GREEN}Codex PreToolUse hook registered{RESET}")
|
|
363
|
-
if not post_already:
|
|
377
|
+
if not post_already or cleaned:
|
|
364
378
|
print(f" {GREEN}Codex PostToolUse hook registered{RESET}")
|
|
365
379
|
else:
|
|
366
380
|
print(f" {GRAY}Codex hooks already registered{RESET}")
|
|
@@ -439,16 +453,27 @@ def _install_claude_hook(hook_path: Path) -> None:
|
|
|
439
453
|
pre.append({"matcher": ".*", "hooks": [{"type": "command", "command": pre_cmd}]})
|
|
440
454
|
changed = True
|
|
441
455
|
|
|
442
|
-
# PostToolUse —
|
|
456
|
+
# PostToolUse — self-contained: python3 /path/hook.py post (no PATH dependency)
|
|
443
457
|
post = hooks.setdefault("PostToolUse", [])
|
|
444
|
-
post_cmd = "
|
|
458
|
+
post_cmd = f"python3 {hook_path} post"
|
|
459
|
+
# Remove stale conductguard-post entries registered by older CLI versions
|
|
460
|
+
stale = "conductguard-post"
|
|
461
|
+
cleaned = False
|
|
462
|
+
for h in post:
|
|
463
|
+
before = len(h.get("hooks", []))
|
|
464
|
+
h["hooks"] = [e for e in h.get("hooks", []) if e.get("command") != stale]
|
|
465
|
+
if len(h["hooks"]) < before:
|
|
466
|
+
cleaned = True
|
|
467
|
+
post[:] = [h for h in post if h.get("hooks")]
|
|
445
468
|
post_already = any(
|
|
446
469
|
e.get("command") == post_cmd
|
|
447
470
|
for h in post
|
|
448
471
|
for e in h.get("hooks", [])
|
|
449
472
|
)
|
|
450
473
|
if not post_already:
|
|
451
|
-
post.append({"matcher": "
|
|
474
|
+
post.append({"matcher": ".*", "hooks": [{"type": "command", "command": post_cmd}]})
|
|
475
|
+
changed = True
|
|
476
|
+
if cleaned:
|
|
452
477
|
changed = True
|
|
453
478
|
|
|
454
479
|
if changed:
|
|
@@ -456,7 +481,7 @@ def _install_claude_hook(hook_path: Path) -> None:
|
|
|
456
481
|
claude_settings.write_text(json.dumps(settings, indent=2))
|
|
457
482
|
if not pre_already:
|
|
458
483
|
print(f" {GREEN}Claude Code PreToolUse hook registered{RESET}")
|
|
459
|
-
if not post_already:
|
|
484
|
+
if not post_already or cleaned:
|
|
460
485
|
print(f" {GREEN}Claude Code PostToolUse hook registered{RESET}")
|
|
461
486
|
else:
|
|
462
487
|
print(f" {GRAY}Claude Code hooks already registered{RESET}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|