onetool-mcp 1.0.0b1__py3-none-any.whl → 1.0.0rc2__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.
Files changed (81) hide show
  1. onetool/cli.py +63 -4
  2. onetool_mcp-1.0.0rc2.dist-info/METADATA +266 -0
  3. onetool_mcp-1.0.0rc2.dist-info/RECORD +129 -0
  4. {onetool_mcp-1.0.0b1.dist-info → onetool_mcp-1.0.0rc2.dist-info}/licenses/LICENSE.txt +1 -1
  5. {onetool_mcp-1.0.0b1.dist-info → onetool_mcp-1.0.0rc2.dist-info}/licenses/NOTICE.txt +54 -64
  6. ot/__main__.py +6 -6
  7. ot/config/__init__.py +48 -46
  8. ot/config/global_templates/__init__.py +2 -2
  9. ot/config/{defaults → global_templates}/diagram-templates/api-flow.mmd +33 -33
  10. ot/config/{defaults → global_templates}/diagram-templates/c4-context.puml +30 -30
  11. ot/config/{defaults → global_templates}/diagram-templates/class-diagram.mmd +87 -87
  12. ot/config/{defaults → global_templates}/diagram-templates/feature-mindmap.mmd +70 -70
  13. ot/config/{defaults → global_templates}/diagram-templates/microservices.d2 +81 -81
  14. ot/config/{defaults → global_templates}/diagram-templates/project-gantt.mmd +37 -37
  15. ot/config/{defaults → global_templates}/diagram-templates/state-machine.mmd +42 -42
  16. ot/config/global_templates/diagram.yaml +167 -0
  17. ot/config/global_templates/onetool.yaml +3 -1
  18. ot/config/{defaults → global_templates}/prompts.yaml +102 -97
  19. ot/config/global_templates/security.yaml +31 -0
  20. ot/config/global_templates/servers.yaml +93 -12
  21. ot/config/global_templates/snippets.yaml +5 -26
  22. ot/config/{defaults → global_templates}/tool_templates/__init__.py +7 -7
  23. ot/config/loader.py +221 -105
  24. ot/config/mcp.py +5 -1
  25. ot/config/secrets.py +192 -190
  26. ot/decorators.py +116 -116
  27. ot/executor/__init__.py +35 -35
  28. ot/executor/base.py +16 -16
  29. ot/executor/fence_processor.py +83 -83
  30. ot/executor/linter.py +142 -142
  31. ot/executor/pep723.py +288 -288
  32. ot/executor/runner.py +20 -6
  33. ot/executor/simple.py +163 -163
  34. ot/executor/validator.py +603 -164
  35. ot/http_client.py +145 -145
  36. ot/logging/__init__.py +37 -37
  37. ot/logging/entry.py +213 -213
  38. ot/logging/format.py +191 -188
  39. ot/logging/span.py +349 -349
  40. ot/meta.py +236 -14
  41. ot/paths.py +32 -49
  42. ot/prompts.py +218 -218
  43. ot/proxy/manager.py +14 -2
  44. ot/registry/__init__.py +189 -189
  45. ot/registry/parser.py +269 -269
  46. ot/server.py +330 -315
  47. ot/shortcuts/__init__.py +15 -15
  48. ot/shortcuts/aliases.py +87 -87
  49. ot/shortcuts/snippets.py +258 -258
  50. ot/stats/__init__.py +35 -35
  51. ot/stats/html.py +2 -2
  52. ot/stats/reader.py +354 -354
  53. ot/stats/timing.py +57 -57
  54. ot/support.py +63 -63
  55. ot/tools.py +1 -1
  56. ot/utils/batch.py +161 -161
  57. ot/utils/cache.py +120 -120
  58. ot/utils/exceptions.py +23 -23
  59. ot/utils/factory.py +178 -179
  60. ot/utils/format.py +65 -65
  61. ot/utils/http.py +202 -202
  62. ot/utils/platform.py +45 -45
  63. ot/utils/truncate.py +69 -69
  64. ot_tools/__init__.py +4 -4
  65. ot_tools/_convert/__init__.py +12 -12
  66. ot_tools/_convert/pdf.py +254 -254
  67. ot_tools/diagram.yaml +167 -167
  68. ot_tools/scaffold.py +2 -2
  69. ot_tools/transform.py +124 -19
  70. ot_tools/web_fetch.py +94 -43
  71. onetool_mcp-1.0.0b1.dist-info/METADATA +0 -163
  72. onetool_mcp-1.0.0b1.dist-info/RECORD +0 -132
  73. ot/config/defaults/bench.yaml +0 -4
  74. ot/config/defaults/onetool.yaml +0 -25
  75. ot/config/defaults/servers.yaml +0 -7
  76. ot/config/defaults/snippets.yaml +0 -4
  77. ot_tools/firecrawl.py +0 -732
  78. {onetool_mcp-1.0.0b1.dist-info → onetool_mcp-1.0.0rc2.dist-info}/WHEEL +0 -0
  79. {onetool_mcp-1.0.0b1.dist-info → onetool_mcp-1.0.0rc2.dist-info}/entry_points.txt +0 -0
  80. /ot/config/{defaults → global_templates}/tool_templates/extension.py +0 -0
  81. /ot/config/{defaults → global_templates}/tool_templates/isolated.py +0 -0
ot/registry/__init__.py CHANGED
@@ -1,189 +1,189 @@
1
- """Tool registry package with auto-discovery for user-defined Python tools.
2
-
3
- The registry scans the `src/ot_tools/` directory, extracts function signatures and
4
- docstrings using AST parsing, and provides formatted context for LLM code generation.
5
- """
6
-
7
- from __future__ import annotations
8
-
9
- import inspect
10
- from typing import TYPE_CHECKING, Any
11
-
12
- from docstring_parser import parse as parse_docstring
13
-
14
- from .models import ArgInfo, ToolInfo
15
- from .registry import ToolRegistry
16
-
17
- if TYPE_CHECKING:
18
- from collections.abc import Callable
19
- from pathlib import Path
20
-
21
- __all__ = [
22
- "ArgInfo",
23
- "ToolInfo",
24
- "ToolRegistry",
25
- "describe_tool",
26
- "get_registry",
27
- "list_tools",
28
- ]
29
-
30
- # Global registry instance
31
- _registry: ToolRegistry | None = None
32
-
33
-
34
- def _build_tool_info_from_callable(
35
- name: str,
36
- func: Callable[..., Any],
37
- pack: str | None = None,
38
- ) -> ToolInfo:
39
- """Build ToolInfo from a callable using inspect.
40
-
41
- Args:
42
- name: Full tool name (e.g., "ot.tools").
43
- func: The function object.
44
- pack: Pack name if applicable.
45
-
46
- Returns:
47
- ToolInfo with extracted signature and docstring info.
48
- """
49
- # Get signature
50
- try:
51
- sig = inspect.signature(func)
52
- signature = f"{name}{sig}"
53
- except (ValueError, TypeError):
54
- signature = f"{name}(...)"
55
-
56
- # Parse docstring
57
- doc = func.__doc__ or ""
58
- parsed = parse_docstring(doc)
59
-
60
- # Build args list
61
- args: list[ArgInfo] = []
62
- for param_name, param in sig.parameters.items():
63
- if param_name in ("self", "cls"):
64
- continue
65
-
66
- # Get type annotation
67
- if param.annotation != inspect.Parameter.empty:
68
- param_type = (
69
- param.annotation.__name__
70
- if hasattr(param.annotation, "__name__")
71
- else str(param.annotation)
72
- )
73
- else:
74
- param_type = "Any"
75
-
76
- # Get default value
77
- default = None
78
- if param.default != inspect.Parameter.empty:
79
- default = repr(param.default)
80
-
81
- # Get description from parsed docstring
82
- description = ""
83
- for doc_param in parsed.params:
84
- if doc_param.arg_name == param_name:
85
- description = doc_param.description or ""
86
- break
87
-
88
- args.append(
89
- ArgInfo(
90
- name=param_name,
91
- type=param_type,
92
- default=default,
93
- description=description,
94
- )
95
- )
96
-
97
- # Get return description
98
- returns = (parsed.returns.description or "") if parsed.returns else ""
99
-
100
- return ToolInfo(
101
- name=name,
102
- pack=pack,
103
- module=func.__module__,
104
- signature=signature,
105
- description=parsed.short_description or "",
106
- args=args,
107
- returns=returns,
108
- )
109
-
110
-
111
- def _register_ot_pack(registry: ToolRegistry) -> None:
112
- """Register the ot pack tools in the registry.
113
-
114
- The ot pack provides introspection functions that need parameter
115
- shorthand support like other tools.
116
- """
117
- from ot.meta import PACK_NAME, get_ot_pack_functions
118
-
119
- ot_functions = get_ot_pack_functions()
120
-
121
- for func_name, func in ot_functions.items():
122
- full_name = f"{PACK_NAME}.{func_name}"
123
- tool_info = _build_tool_info_from_callable(full_name, func, pack=PACK_NAME)
124
- registry.register_tool(tool_info)
125
-
126
-
127
- def get_registry(tools_path: Path | None = None, rescan: bool = False) -> ToolRegistry:
128
- """Get or create the global tool registry.
129
-
130
- Uses config's tools_dir glob patterns if available, otherwise falls back
131
- to the provided tools_path or default 'src/ot_tools/' directory.
132
-
133
- Args:
134
- tools_path: Path to tools directory (fallback if no config).
135
- rescan: If True, rescan even if registry exists.
136
-
137
- Returns:
138
- ToolRegistry instance with discovered tools.
139
- """
140
- from ot.config.loader import get_config
141
-
142
- global _registry
143
-
144
- if _registry is None:
145
- _registry = ToolRegistry(tools_path)
146
- # Use config's tool files if available
147
- config = get_config()
148
- tool_files = config.get_tool_files()
149
- if tool_files:
150
- _registry.scan_files(tool_files)
151
- else:
152
- _registry.scan_directory()
153
- # Register ot pack tools for param shorthand support
154
- _register_ot_pack(_registry)
155
- elif rescan:
156
- # Rescan using config's tool files
157
- config = get_config()
158
- tool_files = config.get_tool_files()
159
- if tool_files:
160
- _registry.scan_files(tool_files)
161
- else:
162
- _registry.scan_directory()
163
- # Re-register ot pack tools after rescan
164
- _register_ot_pack(_registry)
165
-
166
- return _registry
167
-
168
-
169
- def list_tools() -> str:
170
- """List all registered tools.
171
-
172
- Returns:
173
- Summary of all registered tools.
174
- """
175
- registry = get_registry(rescan=True)
176
- return registry.format_summary()
177
-
178
-
179
- def describe_tool(name: str) -> str:
180
- """Describe a specific tool.
181
-
182
- Args:
183
- name: Tool function name.
184
-
185
- Returns:
186
- Detailed tool description.
187
- """
188
- registry = get_registry()
189
- return registry.describe_tool(name)
1
+ """Tool registry package with auto-discovery for user-defined Python tools.
2
+
3
+ The registry scans the `src/ot_tools/` directory, extracts function signatures and
4
+ docstrings using AST parsing, and provides formatted context for LLM code generation.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import inspect
10
+ from typing import TYPE_CHECKING, Any
11
+
12
+ from docstring_parser import parse as parse_docstring
13
+
14
+ from .models import ArgInfo, ToolInfo
15
+ from .registry import ToolRegistry
16
+
17
+ if TYPE_CHECKING:
18
+ from collections.abc import Callable
19
+ from pathlib import Path
20
+
21
+ __all__ = [
22
+ "ArgInfo",
23
+ "ToolInfo",
24
+ "ToolRegistry",
25
+ "describe_tool",
26
+ "get_registry",
27
+ "list_tools",
28
+ ]
29
+
30
+ # Global registry instance
31
+ _registry: ToolRegistry | None = None
32
+
33
+
34
+ def _build_tool_info_from_callable(
35
+ name: str,
36
+ func: Callable[..., Any],
37
+ pack: str | None = None,
38
+ ) -> ToolInfo:
39
+ """Build ToolInfo from a callable using inspect.
40
+
41
+ Args:
42
+ name: Full tool name (e.g., "ot.tools").
43
+ func: The function object.
44
+ pack: Pack name if applicable.
45
+
46
+ Returns:
47
+ ToolInfo with extracted signature and docstring info.
48
+ """
49
+ # Get signature
50
+ try:
51
+ sig = inspect.signature(func)
52
+ signature = f"{name}{sig}"
53
+ except (ValueError, TypeError):
54
+ signature = f"{name}(...)"
55
+
56
+ # Parse docstring
57
+ doc = func.__doc__ or ""
58
+ parsed = parse_docstring(doc)
59
+
60
+ # Build args list
61
+ args: list[ArgInfo] = []
62
+ for param_name, param in sig.parameters.items():
63
+ if param_name in ("self", "cls"):
64
+ continue
65
+
66
+ # Get type annotation
67
+ if param.annotation != inspect.Parameter.empty:
68
+ param_type = (
69
+ param.annotation.__name__
70
+ if hasattr(param.annotation, "__name__")
71
+ else str(param.annotation)
72
+ )
73
+ else:
74
+ param_type = "Any"
75
+
76
+ # Get default value
77
+ default = None
78
+ if param.default != inspect.Parameter.empty:
79
+ default = repr(param.default)
80
+
81
+ # Get description from parsed docstring
82
+ description = ""
83
+ for doc_param in parsed.params:
84
+ if doc_param.arg_name == param_name:
85
+ description = doc_param.description or ""
86
+ break
87
+
88
+ args.append(
89
+ ArgInfo(
90
+ name=param_name,
91
+ type=param_type,
92
+ default=default,
93
+ description=description,
94
+ )
95
+ )
96
+
97
+ # Get return description
98
+ returns = (parsed.returns.description or "") if parsed.returns else ""
99
+
100
+ return ToolInfo(
101
+ name=name,
102
+ pack=pack,
103
+ module=func.__module__,
104
+ signature=signature,
105
+ description=parsed.short_description or "",
106
+ args=args,
107
+ returns=returns,
108
+ )
109
+
110
+
111
+ def _register_ot_pack(registry: ToolRegistry) -> None:
112
+ """Register the ot pack tools in the registry.
113
+
114
+ The ot pack provides introspection functions that need parameter
115
+ shorthand support like other tools.
116
+ """
117
+ from ot.meta import PACK_NAME, get_ot_pack_functions
118
+
119
+ ot_functions = get_ot_pack_functions()
120
+
121
+ for func_name, func in ot_functions.items():
122
+ full_name = f"{PACK_NAME}.{func_name}"
123
+ tool_info = _build_tool_info_from_callable(full_name, func, pack=PACK_NAME)
124
+ registry.register_tool(tool_info)
125
+
126
+
127
+ def get_registry(tools_path: Path | None = None, rescan: bool = False) -> ToolRegistry:
128
+ """Get or create the global tool registry.
129
+
130
+ Uses config's tools_dir glob patterns if available, otherwise falls back
131
+ to the provided tools_path or default 'src/ot_tools/' directory.
132
+
133
+ Args:
134
+ tools_path: Path to tools directory (fallback if no config).
135
+ rescan: If True, rescan even if registry exists.
136
+
137
+ Returns:
138
+ ToolRegistry instance with discovered tools.
139
+ """
140
+ from ot.config.loader import get_config
141
+
142
+ global _registry
143
+
144
+ if _registry is None:
145
+ _registry = ToolRegistry(tools_path)
146
+ # Use config's tool files if available
147
+ config = get_config()
148
+ tool_files = config.get_tool_files()
149
+ if tool_files:
150
+ _registry.scan_files(tool_files)
151
+ else:
152
+ _registry.scan_directory()
153
+ # Register ot pack tools for param shorthand support
154
+ _register_ot_pack(_registry)
155
+ elif rescan:
156
+ # Rescan using config's tool files
157
+ config = get_config()
158
+ tool_files = config.get_tool_files()
159
+ if tool_files:
160
+ _registry.scan_files(tool_files)
161
+ else:
162
+ _registry.scan_directory()
163
+ # Re-register ot pack tools after rescan
164
+ _register_ot_pack(_registry)
165
+
166
+ return _registry
167
+
168
+
169
+ def list_tools() -> str:
170
+ """List all registered tools.
171
+
172
+ Returns:
173
+ Summary of all registered tools.
174
+ """
175
+ registry = get_registry(rescan=True)
176
+ return registry.format_summary()
177
+
178
+
179
+ def describe_tool(name: str) -> str:
180
+ """Describe a specific tool.
181
+
182
+ Args:
183
+ name: Tool function name.
184
+
185
+ Returns:
186
+ Detailed tool description.
187
+ """
188
+ registry = get_registry()
189
+ return registry.describe_tool(name)