golf-mcp 0.2.14__py3-none-any.whl → 0.2.15__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.
Potentially problematic release.
This version of golf-mcp might be problematic. Click here for more details.
- golf/__init__.py +1 -1
- golf/core/builder.py +11 -4
- golf/core/transformer.py +47 -17
- {golf_mcp-0.2.14.dist-info → golf_mcp-0.2.15.dist-info}/METADATA +1 -1
- {golf_mcp-0.2.14.dist-info → golf_mcp-0.2.15.dist-info}/RECORD +9 -9
- {golf_mcp-0.2.14.dist-info → golf_mcp-0.2.15.dist-info}/WHEEL +0 -0
- {golf_mcp-0.2.14.dist-info → golf_mcp-0.2.15.dist-info}/entry_points.txt +0 -0
- {golf_mcp-0.2.14.dist-info → golf_mcp-0.2.15.dist-info}/licenses/LICENSE +0 -0
- {golf_mcp-0.2.14.dist-info → golf_mcp-0.2.15.dist-info}/top_level.txt +0 -0
golf/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.2.
|
|
1
|
+
__version__ = "0.2.15"
|
golf/core/builder.py
CHANGED
|
@@ -341,6 +341,13 @@ class CodeGenerator:
|
|
|
341
341
|
self.manifest = {}
|
|
342
342
|
self.shared_files = {}
|
|
343
343
|
self.import_map = {}
|
|
344
|
+
self._root_files_cache = None # Cache for discovered root files
|
|
345
|
+
|
|
346
|
+
def _get_cached_root_files(self) -> dict[str, Path]:
|
|
347
|
+
"""Get cached root files, discovering them only once."""
|
|
348
|
+
if self._root_files_cache is None:
|
|
349
|
+
self._root_files_cache = discover_root_files(self.project_path)
|
|
350
|
+
return self._root_files_cache
|
|
344
351
|
|
|
345
352
|
def generate(self) -> None:
|
|
346
353
|
"""Generate the FastMCP application code."""
|
|
@@ -386,7 +393,7 @@ class CodeGenerator:
|
|
|
386
393
|
def _generate_root_file_imports(self) -> list[str]:
|
|
387
394
|
"""Generate import statements for automatically discovered root files."""
|
|
388
395
|
root_file_imports = []
|
|
389
|
-
discovered_files =
|
|
396
|
+
discovered_files = self._get_cached_root_files()
|
|
390
397
|
|
|
391
398
|
if discovered_files:
|
|
392
399
|
root_file_imports.append("# Import root-level Python files")
|
|
@@ -401,7 +408,7 @@ class CodeGenerator:
|
|
|
401
408
|
|
|
402
409
|
def _get_root_file_modules(self) -> set[str]:
|
|
403
410
|
"""Get set of root file module names for import transformation."""
|
|
404
|
-
discovered_files =
|
|
411
|
+
discovered_files = self._get_cached_root_files()
|
|
405
412
|
return {Path(filename).stem for filename in discovered_files.keys()}
|
|
406
413
|
|
|
407
414
|
def _create_directory_structure(self) -> None:
|
|
@@ -1612,8 +1619,8 @@ def build_project(
|
|
|
1612
1619
|
shutil.copy2(health_path, output_dir)
|
|
1613
1620
|
console.print(get_status_text("success", "Health script copied to build directory"))
|
|
1614
1621
|
|
|
1615
|
-
# Copy any additional Python files from project root
|
|
1616
|
-
discovered_root_files =
|
|
1622
|
+
# Copy any additional Python files from project root (reuse cached discovery from generator)
|
|
1623
|
+
discovered_root_files = generator._get_cached_root_files()
|
|
1617
1624
|
|
|
1618
1625
|
for filename, file_path in discovered_root_files.items():
|
|
1619
1626
|
dest_path = output_dir / filename
|
golf/core/transformer.py
CHANGED
|
@@ -37,26 +37,53 @@ class ImportTransformer(ast.NodeTransformer):
|
|
|
37
37
|
self.project_root = project_root
|
|
38
38
|
self.root_file_modules = root_file_modules or set()
|
|
39
39
|
|
|
40
|
+
def _calculate_import_depth(self) -> int:
|
|
41
|
+
"""Calculate the relative import depth needed to reach build root from component location."""
|
|
42
|
+
try:
|
|
43
|
+
# Get component path relative to project root
|
|
44
|
+
relative_path = self.target_path.relative_to(self.project_root)
|
|
45
|
+
|
|
46
|
+
# Count directory levels: components/tools/weather.py = 2 levels, needs level=2
|
|
47
|
+
# components/tools/api/handler.py = 3 levels, needs level=3
|
|
48
|
+
# Build root contains the root files, so depth = number of path parts
|
|
49
|
+
return len(relative_path.parts) - 1 # Subtract 1 for the filename itself
|
|
50
|
+
|
|
51
|
+
except ValueError:
|
|
52
|
+
# Fallback to level=3 if path calculation fails
|
|
53
|
+
return 3
|
|
54
|
+
|
|
40
55
|
def visit_Import(self, node: ast.Import) -> Any:
|
|
41
56
|
"""Transform import statements."""
|
|
42
|
-
# Check if any of the imported names are root file modules
|
|
43
57
|
new_names = []
|
|
58
|
+
|
|
44
59
|
for alias in node.names:
|
|
45
60
|
module_name = alias.name
|
|
46
61
|
|
|
47
|
-
# If this is a root file module, we need to adjust the import path
|
|
48
62
|
if module_name in self.root_file_modules:
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
# Calculate dynamic depth based on component location
|
|
64
|
+
depth = self._calculate_import_depth()
|
|
65
|
+
|
|
66
|
+
# Convert to from-import: import config -> from ...config import config
|
|
67
|
+
# Or if there's an asname: import config as cfg -> from ...config import config as cfg
|
|
68
|
+
if alias.asname:
|
|
69
|
+
# import config as cfg -> from ...config import config as cfg
|
|
70
|
+
import_name = module_name
|
|
71
|
+
asname = alias.asname
|
|
72
|
+
else:
|
|
73
|
+
# import config -> from ...config import config
|
|
74
|
+
import_name = module_name
|
|
75
|
+
asname = None
|
|
76
|
+
|
|
77
|
+
# Return a from-import instead of continuing with import
|
|
78
|
+
return ast.ImportFrom(
|
|
79
|
+
module=module_name, names=[ast.alias(name=import_name, asname=asname)], level=depth
|
|
80
|
+
)
|
|
53
81
|
else:
|
|
54
82
|
new_names.append(alias)
|
|
55
83
|
|
|
56
|
-
# If
|
|
57
|
-
if
|
|
84
|
+
# If no root modules, return original or modified import
|
|
85
|
+
if new_names != list(node.names):
|
|
58
86
|
return ast.Import(names=new_names)
|
|
59
|
-
|
|
60
87
|
return node
|
|
61
88
|
|
|
62
89
|
def visit_ImportFrom(self, node: ast.ImportFrom) -> Any:
|
|
@@ -66,8 +93,9 @@ class ImportTransformer(ast.NodeTransformer):
|
|
|
66
93
|
|
|
67
94
|
# Check if this is importing from a root file module
|
|
68
95
|
if node.level == 0 and node.module in self.root_file_modules:
|
|
69
|
-
#
|
|
70
|
-
|
|
96
|
+
# Calculate dynamic depth instead of using hardcoded level=3
|
|
97
|
+
depth = self._calculate_import_depth()
|
|
98
|
+
return ast.ImportFrom(module=node.module, names=node.names, level=depth)
|
|
71
99
|
|
|
72
100
|
# Handle relative imports
|
|
73
101
|
if node.level > 0:
|
|
@@ -175,13 +203,10 @@ def transform_component(
|
|
|
175
203
|
if isinstance(node, ast.Import | ast.ImportFrom):
|
|
176
204
|
imports.append(node)
|
|
177
205
|
|
|
178
|
-
#
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
# Build full transformed code
|
|
182
|
-
transformed_code = transformed_imports + "\n\n"
|
|
206
|
+
# Build full transformed code - start with docstring first (Python convention)
|
|
207
|
+
transformed_code = ""
|
|
183
208
|
|
|
184
|
-
# Add docstring if present, using proper triple quotes for multi-line docstrings
|
|
209
|
+
# Add docstring first if present, using proper triple quotes for multi-line docstrings
|
|
185
210
|
if docstring:
|
|
186
211
|
# Check if docstring contains newlines
|
|
187
212
|
if "\n" in docstring:
|
|
@@ -191,6 +216,11 @@ def transform_component(
|
|
|
191
216
|
# Use single quotes for single-line docstrings
|
|
192
217
|
transformed_code += f'"{docstring}"\n\n'
|
|
193
218
|
|
|
219
|
+
# Add transformed imports after docstring
|
|
220
|
+
if imports:
|
|
221
|
+
transformed_imports = ast.unparse(ast.Module(body=imports, type_ignores=[]))
|
|
222
|
+
transformed_code += transformed_imports + "\n\n"
|
|
223
|
+
|
|
194
224
|
# Add the rest of the code except imports and the original docstring
|
|
195
225
|
remaining_nodes = []
|
|
196
226
|
for node in tree.body:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
golf/__init__.py,sha256=
|
|
1
|
+
golf/__init__.py,sha256=ogr0x4sazo5ruMrKOQDYO_YrTwtaXZTE8fKnwCajH7I,23
|
|
2
2
|
golf/auth/__init__.py,sha256=sYWjWXGR70Ae87znseeBK2YWl8S1-qn_hndKf2xMULk,8173
|
|
3
3
|
golf/auth/api_key.py,sha256=OonqTlG6USJxqK8TlPviJTv7sgYmTVfCxG_JsEjnEM4,2320
|
|
4
4
|
golf/auth/factory.py,sha256=3-il1GbjjZlQfvWUZs-09r61Y_-b5cYEegWF7sY_cUs,13128
|
|
@@ -13,14 +13,14 @@ golf/commands/build.py,sha256=sLq9lSW4naq2vIlBreKI5SGnviQrhBWw13zfOZOKhuM,2293
|
|
|
13
13
|
golf/commands/init.py,sha256=KkAg_3-KxBDFOcZqUHqcPAkDipykFVaLWpQ2tydnVPk,9617
|
|
14
14
|
golf/commands/run.py,sha256=2fdjqTfzQL-dFOqptkl-K2jel8VWpevAx0somcjNsPI,4576
|
|
15
15
|
golf/core/__init__.py,sha256=4bKeskJ2fPaZqkz2xQScSa3phRLLrmrczwSL632jv-o,52
|
|
16
|
-
golf/core/builder.py,sha256=
|
|
16
|
+
golf/core/builder.py,sha256=A-QESun8Bp5tI3cimSkunudphSFzrvWWdlEAZOjMx60,81217
|
|
17
17
|
golf/core/builder_auth.py,sha256=f0w9TmxvNjxglcWY8NGULZJ8mwLqtUFFb2QHzgC0xAk,8219
|
|
18
18
|
golf/core/builder_metrics.py,sha256=wrXdE4_XWx7fUXnp61WU7rCBO-aG-4YzCMV6yO0z9Dg,8594
|
|
19
19
|
golf/core/builder_telemetry.py,sha256=86bp7UlMUN6JyQRrZ5EizovP6AJ_q65OANJTeJXDIKc,3421
|
|
20
20
|
golf/core/config.py,sha256=kL440b8i1dF8jdKeYwZZ04HdotX5CAlTyxR1ZyML-Iw,6850
|
|
21
21
|
golf/core/parser.py,sha256=f9WqmLWlFuXQCObl2Qmna9bp_Bo0p0eIlukzwFaBSzo,43373
|
|
22
22
|
golf/core/telemetry.py,sha256=dXoWrgrQpj_HGrl_8TBZmRnuLxFKEn0GSDWQ9qq3ZQM,15686
|
|
23
|
-
golf/core/transformer.py,sha256=
|
|
23
|
+
golf/core/transformer.py,sha256=V5tC2eV6uCBZsiwi_CC1GjCnZ1Lrra-vVEHj09h5A6Q,9739
|
|
24
24
|
golf/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
golf/examples/basic/.env.example,sha256=Ktdc2Qta05smPItYHnEHhVxYPkq5JJ7i2aI5pOyyQx4,162
|
|
26
26
|
golf/examples/basic/README.md,sha256=p8KMyaNXGZtrbgckW-Thu_5RKXViGiyZ5hHEiJ6Zc-U,3283
|
|
@@ -44,9 +44,9 @@ golf/utilities/__init__.py,sha256=X9iY9yi3agz1GVcn8-qWeOCt8CSSsruHxqPNtiF63TY,53
|
|
|
44
44
|
golf/utilities/context.py,sha256=DGGvhVe---QMhy0wtdWhNp-_WVk1NvAcOFn0uBKBpYo,1579
|
|
45
45
|
golf/utilities/elicitation.py,sha256=MParZZZsY45s70-KXduHa6IvpWXnLW2FCPfrGijMaHs,5223
|
|
46
46
|
golf/utilities/sampling.py,sha256=88nDv-trBE4gZQbcnMjXl3LW6TiIhv5zR_cuEIGjaIM,7233
|
|
47
|
-
golf_mcp-0.2.
|
|
48
|
-
golf_mcp-0.2.
|
|
49
|
-
golf_mcp-0.2.
|
|
50
|
-
golf_mcp-0.2.
|
|
51
|
-
golf_mcp-0.2.
|
|
52
|
-
golf_mcp-0.2.
|
|
47
|
+
golf_mcp-0.2.15.dist-info/licenses/LICENSE,sha256=5_j2f6fTJmvfmUewzElhkpAaXg2grVoxKouOA8ihV6E,11348
|
|
48
|
+
golf_mcp-0.2.15.dist-info/METADATA,sha256=9kX1_b5goRhyDLqdd0QI_S8oiXO42fz_44_WkXhdsVw,9414
|
|
49
|
+
golf_mcp-0.2.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
50
|
+
golf_mcp-0.2.15.dist-info/entry_points.txt,sha256=5y7rHYM8jGpU-nfwdknCm5XsApLulqsnA37MO6BUTYg,43
|
|
51
|
+
golf_mcp-0.2.15.dist-info/top_level.txt,sha256=BQToHcBUufdyhp9ONGMIvPE40jMEtmI20lYaKb4hxOg,5
|
|
52
|
+
golf_mcp-0.2.15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|