anosys-claude-code 0.2.1__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.
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: anosys-claude-code
3
+ Version: 0.2.1
4
+ Summary: AnoSys observability hook for Claude Code — automatic audit logging of Claude Code sessions
5
+ Author-email: AnoSys <support@anosys.ai>
6
+ Project-URL: Homepage, https://anosys.ai
7
+ Project-URL: Documentation, https://docs.anosys.ai
8
+ Project-URL: Repository, https://github.com/anosys-ai/anosys-sdk
9
+ Keywords: anosys,claude,claude-code,observability,monitoring,audit,llm
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Topic :: System :: Monitoring
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: requests>=2.25.1
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "anosys-claude-code"
7
+ version = "0.2.1"
8
+ description = "AnoSys observability hook for Claude Code — automatic audit logging of Claude Code sessions"
9
+ authors = [{name = "AnoSys", email = "support@anosys.ai"}]
10
+ readme = "README.md"
11
+ license = {file = "LICENSE"}
12
+ requires-python = ">=3.10"
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: Apache Software License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ "Topic :: System :: Monitoring",
23
+ ]
24
+ keywords = ["anosys", "claude", "claude-code", "observability", "monitoring", "audit", "llm"]
25
+ dependencies = [
26
+ "requests>=2.25.1",
27
+ ]
28
+
29
+ [project.scripts]
30
+ anosys-claude-code = "anosys_sdk_claude_code.cli:main"
31
+
32
+ [project.urls]
33
+ Homepage = "https://anosys.ai"
34
+ Documentation = "https://docs.anosys.ai"
35
+ Repository = "https://github.com/anosys-ai/anosys-sdk"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+
40
+ [tool.setuptools.package-data]
41
+ "anosys_sdk_claude_code" = ["py.typed"]
42
+
43
+ [tool.ruff.lint.per-file-ignores]
44
+ "src/anosys_sdk_claude_code/mapper.py" = ["E701", "E702"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: anosys-claude-code
3
+ Version: 0.2.1
4
+ Summary: AnoSys observability hook for Claude Code — automatic audit logging of Claude Code sessions
5
+ Author-email: AnoSys <support@anosys.ai>
6
+ Project-URL: Homepage, https://anosys.ai
7
+ Project-URL: Documentation, https://docs.anosys.ai
8
+ Project-URL: Repository, https://github.com/anosys-ai/anosys-sdk
9
+ Keywords: anosys,claude,claude-code,observability,monitoring,audit,llm
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Topic :: System :: Monitoring
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: requests>=2.25.1
@@ -0,0 +1,14 @@
1
+ pyproject.toml
2
+ src/anosys_claude_code.egg-info/PKG-INFO
3
+ src/anosys_claude_code.egg-info/SOURCES.txt
4
+ src/anosys_claude_code.egg-info/dependency_links.txt
5
+ src/anosys_claude_code.egg-info/entry_points.txt
6
+ src/anosys_claude_code.egg-info/requires.txt
7
+ src/anosys_claude_code.egg-info/top_level.txt
8
+ src/anosys_sdk_claude_code/__init__.py
9
+ src/anosys_sdk_claude_code/cli.py
10
+ src/anosys_sdk_claude_code/hook_runner.py
11
+ src/anosys_sdk_claude_code/installer.py
12
+ src/anosys_sdk_claude_code/mapper.py
13
+ src/anosys_sdk_claude_code/py.typed
14
+ tests/test_claude_code.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ anosys-claude-code = anosys_sdk_claude_code.cli:main
@@ -0,0 +1 @@
1
+ anosys_sdk_claude_code
@@ -0,0 +1,9 @@
1
+ """
2
+ AnoSys Claude Code integration — observability hook for Claude Code sessions.
3
+ """
4
+
5
+ from anosys_sdk_claude_code.installer import update_env, update_stop_hooks
6
+ from anosys_sdk_claude_code.mapper import transform_record
7
+
8
+ __version__ = "0.2.1"
9
+ __all__ = ["transform_record", "update_env", "update_stop_hooks"]
@@ -0,0 +1,151 @@
1
+ """
2
+ CLI entry point for anosys-claude-code.
3
+
4
+ Commands:
5
+ install Register the AnoSys Stop hook in ~/.claude/settings.json
6
+ uninstall Remove the AnoSys Stop hook from ~/.claude/settings.json
7
+ status Show current hook registration status
8
+ run Execute the hook (invoked by Claude Code on every Stop event)
9
+ """
10
+
11
+ import argparse
12
+ import asyncio
13
+ import sys
14
+
15
+ from anosys_sdk_claude_code.installer import (
16
+ BACKUP_PATH,
17
+ SETTINGS_PATH,
18
+ backup,
19
+ get_anosys_hook_command,
20
+ has_anosys_hook,
21
+ load_settings,
22
+ remove_env,
23
+ remove_stop_hooks,
24
+ update_env,
25
+ update_stop_hooks,
26
+ write_atomic,
27
+ )
28
+
29
+ HOOK_COMMAND = "anosys-claude-code run"
30
+ DEFAULT_ENDPOINT = "https://api.anosys.ai"
31
+
32
+
33
+ def _prompt(prompt: str, default: str = "") -> str:
34
+ try:
35
+ val = input(prompt).strip()
36
+ return val if val else default
37
+ except (EOFError, KeyboardInterrupt):
38
+ print()
39
+ sys.exit(0)
40
+
41
+
42
+ def cmd_install(args: argparse.Namespace) -> None:
43
+ print("\nAnoSys Claude Code Hook Installer")
44
+ print("=" * 40)
45
+
46
+ api_key = args.api_key
47
+ if not api_key:
48
+ api_key = _prompt(
49
+ "AnoSys API key (leave blank to skip, can set ANOSYS_HOOK_API_KEY later): "
50
+ )
51
+
52
+ endpoint = args.endpoint or _prompt(
53
+ f"AnoSys endpoint URL [{DEFAULT_ENDPOINT}]: ", DEFAULT_ENDPOINT
54
+ )
55
+
56
+ redaction = args.redaction
57
+ if not redaction and not args.no_redaction:
58
+ choice = _prompt("Enable content redaction? (y/N): ", "n").lower()
59
+ redaction = choice == 'y'
60
+
61
+ new_env: dict = {
62
+ "ANOSYS_HOOK_ENDPOINT_URL": endpoint,
63
+ }
64
+ if api_key:
65
+ new_env["ANOSYS_HOOK_API_KEY"] = api_key
66
+ if redaction:
67
+ new_env["REDACTION"] = "true"
68
+
69
+ print(f"\nUpdating {SETTINGS_PATH} ...")
70
+ settings = load_settings()
71
+ backup()
72
+ settings = update_env(settings, new_env)
73
+ settings = update_stop_hooks(settings, HOOK_COMMAND)
74
+ write_atomic(SETTINGS_PATH, settings)
75
+
76
+ print(f" Backed up original settings -> {BACKUP_PATH}")
77
+ print(f" Hook command registered: {HOOK_COMMAND}")
78
+ print(f" Endpoint: {endpoint}")
79
+ if api_key:
80
+ print(f" API key: {'*' * (len(api_key) - 4)}{api_key[-4:]}")
81
+ print(f" Redaction: {'enabled' if redaction else 'disabled'}")
82
+ print("\nDone. The hook will fire automatically after each Claude Code session.")
83
+
84
+
85
+ def cmd_uninstall(args: argparse.Namespace) -> None:
86
+ print(f"\nRemoving AnoSys hook from {SETTINGS_PATH} ...")
87
+ settings = load_settings()
88
+ if not has_anosys_hook(settings):
89
+ print(" No AnoSys hook found — nothing to remove.")
90
+ return
91
+ backup()
92
+ settings = remove_stop_hooks(settings)
93
+ settings = remove_env(settings)
94
+ write_atomic(SETTINGS_PATH, settings)
95
+ print(f" Backed up original settings -> {BACKUP_PATH}")
96
+ print(" AnoSys hook removed successfully.")
97
+
98
+
99
+ def cmd_status(args: argparse.Namespace) -> None:
100
+ settings = load_settings()
101
+ if has_anosys_hook(settings):
102
+ cmd = get_anosys_hook_command(settings)
103
+ print("AnoSys hook is INSTALLED")
104
+ print(f" Command: {cmd}")
105
+ env = settings.get("env", {})
106
+ endpoint = env.get("ANOSYS_HOOK_ENDPOINT_URL", "(not set)")
107
+ has_key = "ANOSYS_HOOK_API_KEY" in env
108
+ redaction = env.get("REDACTION", "false")
109
+ print(f" Endpoint: {endpoint}")
110
+ print(f" API key: {'set' if has_key else 'not set'}")
111
+ print(f" Redaction: {redaction}")
112
+ else:
113
+ print("AnoSys hook is NOT installed.")
114
+ print(" Run 'anosys-claude-code install' to set it up.")
115
+
116
+
117
+ def cmd_run(args: argparse.Namespace) -> None:
118
+ from anosys_sdk_claude_code.hook_runner import main
119
+ asyncio.run(main())
120
+
121
+
122
+ def main() -> None:
123
+ parser = argparse.ArgumentParser(
124
+ prog="anosys-claude-code",
125
+ description="AnoSys observability hook for Claude Code"
126
+ )
127
+ sub = parser.add_subparsers(dest="command", metavar="COMMAND")
128
+ sub.required = True
129
+
130
+ p_install = sub.add_parser("install", help="Register the AnoSys Stop hook")
131
+ p_install.add_argument("--api-key", metavar="KEY", help="AnoSys API key")
132
+ p_install.add_argument("--endpoint", metavar="URL", help=f"Endpoint URL (default: {DEFAULT_ENDPOINT})")
133
+ p_install.add_argument("--redaction", action="store_true", help="Enable content redaction")
134
+ p_install.add_argument("--no-redaction", action="store_true", help="Skip redaction prompt")
135
+ p_install.set_defaults(func=cmd_install)
136
+
137
+ p_uninstall = sub.add_parser("uninstall", help="Remove the AnoSys Stop hook")
138
+ p_uninstall.set_defaults(func=cmd_uninstall)
139
+
140
+ p_status = sub.add_parser("status", help="Show hook registration status")
141
+ p_status.set_defaults(func=cmd_status)
142
+
143
+ p_run = sub.add_parser("run", help="Execute the hook (called by Claude Code)")
144
+ p_run.set_defaults(func=cmd_run)
145
+
146
+ args = parser.parse_args()
147
+ args.func(args)
148
+
149
+
150
+ if __name__ == "__main__":
151
+ main()