scitex 2.14.0__py3-none-any.whl → 2.15.2__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.
- scitex/__init__.py +71 -17
- scitex/_env_loader.py +156 -0
- scitex/_mcp_resources/__init__.py +37 -0
- scitex/_mcp_resources/_cheatsheet.py +135 -0
- scitex/_mcp_resources/_figrecipe.py +138 -0
- scitex/_mcp_resources/_formats.py +102 -0
- scitex/_mcp_resources/_modules.py +337 -0
- scitex/_mcp_resources/_session.py +149 -0
- scitex/_mcp_tools/__init__.py +4 -0
- scitex/_mcp_tools/audio.py +66 -0
- scitex/_mcp_tools/diagram.py +11 -95
- scitex/_mcp_tools/introspect.py +210 -0
- scitex/_mcp_tools/plt.py +260 -305
- scitex/_mcp_tools/scholar.py +74 -0
- scitex/_mcp_tools/social.py +244 -0
- scitex/_mcp_tools/template.py +24 -0
- scitex/_mcp_tools/writer.py +21 -204
- scitex/ai/_gen_ai/_PARAMS.py +10 -7
- scitex/ai/classification/reporters/_SingleClassificationReporter.py +45 -1603
- scitex/ai/classification/reporters/_mixins/__init__.py +36 -0
- scitex/ai/classification/reporters/_mixins/_constants.py +67 -0
- scitex/ai/classification/reporters/_mixins/_cv_summary.py +387 -0
- scitex/ai/classification/reporters/_mixins/_feature_importance.py +119 -0
- scitex/ai/classification/reporters/_mixins/_metrics.py +275 -0
- scitex/ai/classification/reporters/_mixins/_plotting.py +179 -0
- scitex/ai/classification/reporters/_mixins/_reports.py +153 -0
- scitex/ai/classification/reporters/_mixins/_storage.py +160 -0
- scitex/ai/classification/timeseries/_TimeSeriesSlidingWindowSplit.py +30 -1550
- scitex/ai/classification/timeseries/_sliding_window_core.py +467 -0
- scitex/ai/classification/timeseries/_sliding_window_plotting.py +369 -0
- scitex/audio/README.md +40 -36
- scitex/audio/__init__.py +129 -61
- scitex/audio/_branding.py +185 -0
- scitex/audio/_mcp/__init__.py +32 -0
- scitex/audio/_mcp/handlers.py +59 -6
- scitex/audio/_mcp/speak_handlers.py +238 -0
- scitex/audio/_relay.py +225 -0
- scitex/audio/_tts.py +18 -10
- scitex/audio/engines/base.py +17 -10
- scitex/audio/engines/elevenlabs_engine.py +7 -2
- scitex/audio/mcp_server.py +228 -75
- scitex/canvas/README.md +1 -1
- scitex/canvas/editor/_dearpygui/__init__.py +25 -0
- scitex/canvas/editor/_dearpygui/_editor.py +147 -0
- scitex/canvas/editor/_dearpygui/_handlers.py +476 -0
- scitex/canvas/editor/_dearpygui/_panels/__init__.py +17 -0
- scitex/canvas/editor/_dearpygui/_panels/_control.py +119 -0
- scitex/canvas/editor/_dearpygui/_panels/_element_controls.py +190 -0
- scitex/canvas/editor/_dearpygui/_panels/_preview.py +43 -0
- scitex/canvas/editor/_dearpygui/_panels/_sections.py +390 -0
- scitex/canvas/editor/_dearpygui/_plotting.py +187 -0
- scitex/canvas/editor/_dearpygui/_rendering.py +504 -0
- scitex/canvas/editor/_dearpygui/_selection.py +295 -0
- scitex/canvas/editor/_dearpygui/_state.py +93 -0
- scitex/canvas/editor/_dearpygui/_utils.py +61 -0
- scitex/canvas/editor/flask_editor/_core/__init__.py +27 -0
- scitex/canvas/editor/flask_editor/_core/_bbox_extraction.py +200 -0
- scitex/canvas/editor/flask_editor/_core/_editor.py +173 -0
- scitex/canvas/editor/flask_editor/_core/_export_helpers.py +353 -0
- scitex/canvas/editor/flask_editor/_core/_routes_basic.py +190 -0
- scitex/canvas/editor/flask_editor/_core/_routes_export.py +332 -0
- scitex/canvas/editor/flask_editor/_core/_routes_panels.py +252 -0
- scitex/canvas/editor/flask_editor/_core/_routes_save.py +218 -0
- scitex/canvas/editor/flask_editor/_core.py +25 -1684
- scitex/canvas/editor/flask_editor/templates/__init__.py +32 -70
- scitex/cli/__init__.py +38 -43
- scitex/cli/audio.py +76 -27
- scitex/cli/capture.py +13 -20
- scitex/cli/introspect.py +481 -0
- scitex/cli/main.py +200 -109
- scitex/cli/mcp.py +60 -34
- scitex/cli/plt.py +357 -0
- scitex/cli/repro.py +15 -8
- scitex/cli/resource.py +15 -8
- scitex/cli/scholar/__init__.py +23 -8
- scitex/cli/scholar/_crossref_scitex.py +296 -0
- scitex/cli/scholar/_fetch.py +25 -3
- scitex/cli/social.py +314 -0
- scitex/cli/stats.py +15 -8
- scitex/cli/template.py +129 -12
- scitex/cli/tex.py +15 -8
- scitex/cli/writer.py +132 -8
- scitex/cloud/__init__.py +41 -2
- scitex/config/README.md +1 -1
- scitex/config/__init__.py +16 -2
- scitex/config/_env_registry.py +256 -0
- scitex/context/__init__.py +22 -0
- scitex/dev/__init__.py +20 -1
- scitex/diagram/__init__.py +42 -19
- scitex/diagram/mcp_server.py +13 -125
- scitex/gen/__init__.py +50 -14
- scitex/gen/_list_packages.py +4 -4
- scitex/introspect/__init__.py +82 -0
- scitex/introspect/_call_graph.py +303 -0
- scitex/introspect/_class_hierarchy.py +163 -0
- scitex/introspect/_core.py +41 -0
- scitex/introspect/_docstring.py +131 -0
- scitex/introspect/_examples.py +113 -0
- scitex/introspect/_imports.py +271 -0
- scitex/{gen/_inspect_module.py → introspect/_list_api.py} +43 -54
- scitex/introspect/_mcp/__init__.py +41 -0
- scitex/introspect/_mcp/handlers.py +233 -0
- scitex/introspect/_members.py +155 -0
- scitex/introspect/_resolve.py +89 -0
- scitex/introspect/_signature.py +131 -0
- scitex/introspect/_source.py +80 -0
- scitex/introspect/_type_hints.py +172 -0
- scitex/io/_save.py +1 -2
- scitex/io/bundle/README.md +1 -1
- scitex/logging/_formatters.py +19 -9
- scitex/mcp_server.py +98 -5
- scitex/os/__init__.py +4 -0
- scitex/{gen → os}/_check_host.py +4 -5
- scitex/plt/__init__.py +245 -550
- scitex/plt/_subplots/_AxisWrapperMixins/_SeabornMixin/_wrappers.py +5 -10
- scitex/plt/docs/EXTERNAL_PACKAGE_BRANDING.md +149 -0
- scitex/plt/gallery/README.md +1 -1
- scitex/plt/utils/_hitmap/__init__.py +82 -0
- scitex/plt/utils/_hitmap/_artist_extraction.py +343 -0
- scitex/plt/utils/_hitmap/_color_application.py +346 -0
- scitex/plt/utils/_hitmap/_color_conversion.py +121 -0
- scitex/plt/utils/_hitmap/_constants.py +40 -0
- scitex/plt/utils/_hitmap/_hitmap_core.py +334 -0
- scitex/plt/utils/_hitmap/_path_extraction.py +357 -0
- scitex/plt/utils/_hitmap/_query.py +113 -0
- scitex/plt/utils/_hitmap.py +46 -1616
- scitex/plt/utils/_metadata/__init__.py +80 -0
- scitex/plt/utils/_metadata/_artists/__init__.py +25 -0
- scitex/plt/utils/_metadata/_artists/_base.py +195 -0
- scitex/plt/utils/_metadata/_artists/_collections.py +356 -0
- scitex/plt/utils/_metadata/_artists/_extract.py +57 -0
- scitex/plt/utils/_metadata/_artists/_images.py +80 -0
- scitex/plt/utils/_metadata/_artists/_lines.py +261 -0
- scitex/plt/utils/_metadata/_artists/_patches.py +247 -0
- scitex/plt/utils/_metadata/_artists/_text.py +106 -0
- scitex/plt/utils/_metadata/_csv.py +416 -0
- scitex/plt/utils/_metadata/_detect.py +225 -0
- scitex/plt/utils/_metadata/_legend.py +127 -0
- scitex/plt/utils/_metadata/_rounding.py +117 -0
- scitex/plt/utils/_metadata/_verification.py +202 -0
- scitex/schema/README.md +1 -1
- scitex/scholar/__init__.py +8 -0
- scitex/scholar/_mcp/crossref_handlers.py +265 -0
- scitex/scholar/core/Scholar.py +63 -1700
- scitex/scholar/core/_mixins/__init__.py +36 -0
- scitex/scholar/core/_mixins/_enrichers.py +270 -0
- scitex/scholar/core/_mixins/_library_handlers.py +100 -0
- scitex/scholar/core/_mixins/_loaders.py +103 -0
- scitex/scholar/core/_mixins/_pdf_download.py +375 -0
- scitex/scholar/core/_mixins/_pipeline.py +312 -0
- scitex/scholar/core/_mixins/_project_handlers.py +125 -0
- scitex/scholar/core/_mixins/_savers.py +69 -0
- scitex/scholar/core/_mixins/_search.py +103 -0
- scitex/scholar/core/_mixins/_services.py +88 -0
- scitex/scholar/core/_mixins/_url_finding.py +105 -0
- scitex/scholar/crossref_scitex.py +367 -0
- scitex/scholar/docs/EXTERNAL_PACKAGE_BRANDING.md +149 -0
- scitex/scholar/examples/00_run_all.sh +120 -0
- scitex/scholar/jobs/_executors.py +27 -3
- scitex/scholar/pdf_download/ScholarPDFDownloader.py +38 -416
- scitex/scholar/pdf_download/_cli.py +154 -0
- scitex/scholar/pdf_download/strategies/__init__.py +11 -8
- scitex/scholar/pdf_download/strategies/manual_download_fallback.py +80 -3
- scitex/scholar/pipelines/ScholarPipelineBibTeX.py +73 -121
- scitex/scholar/pipelines/ScholarPipelineParallel.py +80 -138
- scitex/scholar/pipelines/ScholarPipelineSingle.py +43 -63
- scitex/scholar/pipelines/_single_steps.py +71 -36
- scitex/scholar/storage/_LibraryManager.py +97 -1695
- scitex/scholar/storage/_mixins/__init__.py +30 -0
- scitex/scholar/storage/_mixins/_bibtex_handlers.py +128 -0
- scitex/scholar/storage/_mixins/_library_operations.py +218 -0
- scitex/scholar/storage/_mixins/_metadata_conversion.py +226 -0
- scitex/scholar/storage/_mixins/_paper_saving.py +456 -0
- scitex/scholar/storage/_mixins/_resolution.py +376 -0
- scitex/scholar/storage/_mixins/_storage_helpers.py +121 -0
- scitex/scholar/storage/_mixins/_symlink_handlers.py +226 -0
- scitex/scholar/url_finder/.tmp/open_url/KNOWN_RESOLVERS.py +462 -0
- scitex/scholar/url_finder/.tmp/open_url/README.md +223 -0
- scitex/scholar/url_finder/.tmp/open_url/_DOIToURLResolver.py +694 -0
- scitex/scholar/url_finder/.tmp/open_url/_OpenURLResolver.py +1160 -0
- scitex/scholar/url_finder/.tmp/open_url/_ResolverLinkFinder.py +344 -0
- scitex/scholar/url_finder/.tmp/open_url/__init__.py +24 -0
- scitex/security/README.md +3 -3
- scitex/session/README.md +1 -1
- scitex/session/__init__.py +26 -7
- scitex/session/_decorator.py +1 -1
- scitex/sh/README.md +1 -1
- scitex/sh/__init__.py +7 -4
- scitex/social/__init__.py +155 -0
- scitex/social/docs/EXTERNAL_PACKAGE_BRANDING.md +149 -0
- scitex/stats/_mcp/_handlers/__init__.py +31 -0
- scitex/stats/_mcp/_handlers/_corrections.py +113 -0
- scitex/stats/_mcp/_handlers/_descriptive.py +78 -0
- scitex/stats/_mcp/_handlers/_effect_size.py +106 -0
- scitex/stats/_mcp/_handlers/_format.py +94 -0
- scitex/stats/_mcp/_handlers/_normality.py +110 -0
- scitex/stats/_mcp/_handlers/_posthoc.py +224 -0
- scitex/stats/_mcp/_handlers/_power.py +247 -0
- scitex/stats/_mcp/_handlers/_recommend.py +102 -0
- scitex/stats/_mcp/_handlers/_run_test.py +279 -0
- scitex/stats/_mcp/_handlers/_stars.py +48 -0
- scitex/stats/_mcp/handlers.py +19 -1171
- scitex/stats/auto/_stat_style.py +175 -0
- scitex/stats/auto/_style_definitions.py +411 -0
- scitex/stats/auto/_styles.py +22 -620
- scitex/stats/descriptive/__init__.py +11 -8
- scitex/stats/descriptive/_ci.py +39 -0
- scitex/stats/power/_power.py +15 -4
- scitex/str/__init__.py +2 -1
- scitex/str/_title_case.py +63 -0
- scitex/template/README.md +1 -1
- scitex/template/__init__.py +25 -10
- scitex/template/_code_templates.py +147 -0
- scitex/template/_mcp/handlers.py +81 -0
- scitex/template/_mcp/tool_schemas.py +55 -0
- scitex/template/_templates/__init__.py +51 -0
- scitex/template/_templates/audio.py +233 -0
- scitex/template/_templates/canvas.py +312 -0
- scitex/template/_templates/capture.py +268 -0
- scitex/template/_templates/config.py +43 -0
- scitex/template/_templates/diagram.py +294 -0
- scitex/template/_templates/io.py +107 -0
- scitex/template/_templates/module.py +53 -0
- scitex/template/_templates/plt.py +202 -0
- scitex/template/_templates/scholar.py +267 -0
- scitex/template/_templates/session.py +130 -0
- scitex/template/_templates/session_minimal.py +43 -0
- scitex/template/_templates/session_plot.py +67 -0
- scitex/template/_templates/session_stats.py +77 -0
- scitex/template/_templates/stats.py +323 -0
- scitex/template/_templates/writer.py +296 -0
- scitex/template/clone_writer_directory.py +5 -5
- scitex/ui/_backends/_email.py +10 -2
- scitex/ui/_backends/_webhook.py +5 -1
- scitex/web/_search_pubmed.py +10 -6
- scitex/writer/README.md +1 -1
- scitex/writer/_mcp/handlers.py +11 -744
- scitex/writer/_mcp/tool_schemas.py +5 -335
- scitex-2.15.2.dist-info/METADATA +648 -0
- {scitex-2.14.0.dist-info → scitex-2.15.2.dist-info}/RECORD +246 -150
- scitex/canvas/editor/flask_editor/templates/_scripts.py +0 -4933
- scitex/canvas/editor/flask_editor/templates/_styles.py +0 -1658
- scitex/dev/plt/data/mpl/PLOTTING_FUNCTIONS.yaml +0 -90
- scitex/dev/plt/data/mpl/PLOTTING_SIGNATURES.yaml +0 -1571
- scitex/dev/plt/data/mpl/PLOTTING_SIGNATURES_DETAILED.yaml +0 -6262
- scitex/dev/plt/data/mpl/SIGNATURES_FLATTENED.yaml +0 -1274
- scitex/dev/plt/data/mpl/dir_ax.txt +0 -459
- scitex/diagram/_compile.py +0 -312
- scitex/diagram/_diagram.py +0 -355
- scitex/diagram/_mcp/__init__.py +0 -4
- scitex/diagram/_mcp/handlers.py +0 -400
- scitex/diagram/_mcp/tool_schemas.py +0 -157
- scitex/diagram/_presets.py +0 -173
- scitex/diagram/_schema.py +0 -182
- scitex/diagram/_split.py +0 -278
- scitex/gen/_ci.py +0 -12
- scitex/gen/_title_case.py +0 -89
- scitex/plt/_mcp/__init__.py +0 -4
- scitex/plt/_mcp/_handlers_annotation.py +0 -102
- scitex/plt/_mcp/_handlers_figure.py +0 -195
- scitex/plt/_mcp/_handlers_plot.py +0 -252
- scitex/plt/_mcp/_handlers_style.py +0 -219
- scitex/plt/_mcp/handlers.py +0 -74
- scitex/plt/_mcp/tool_schemas.py +0 -497
- scitex/plt/mcp_server.py +0 -231
- scitex/scholar/data/.gitkeep +0 -0
- scitex/scholar/data/README.md +0 -44
- scitex/scholar/data/bib_files/bibliography.bib +0 -1952
- scitex/scholar/data/bib_files/neurovista.bib +0 -277
- scitex/scholar/data/bib_files/neurovista_enriched.bib +0 -441
- scitex/scholar/data/bib_files/neurovista_enriched_enriched.bib +0 -441
- scitex/scholar/data/bib_files/neurovista_processed.bib +0 -338
- scitex/scholar/data/bib_files/openaccess.bib +0 -89
- scitex/scholar/data/bib_files/pac-seizure_prediction_enriched.bib +0 -2178
- scitex/scholar/data/bib_files/pac.bib +0 -698
- scitex/scholar/data/bib_files/pac_enriched.bib +0 -1061
- scitex/scholar/data/bib_files/pac_processed.bib +0 -0
- scitex/scholar/data/bib_files/pac_titles.txt +0 -75
- scitex/scholar/data/bib_files/paywalled.bib +0 -98
- scitex/scholar/data/bib_files/related-papers-by-coauthors.bib +0 -58
- scitex/scholar/data/bib_files/related-papers-by-coauthors_enriched.bib +0 -87
- scitex/scholar/data/bib_files/seizure_prediction.bib +0 -694
- scitex/scholar/data/bib_files/seizure_prediction_processed.bib +0 -0
- scitex/scholar/data/bib_files/test_complete_enriched.bib +0 -437
- scitex/scholar/data/bib_files/test_final_enriched.bib +0 -437
- scitex/scholar/data/bib_files/test_seizure.bib +0 -46
- scitex/scholar/data/impact_factor/JCR_IF_2022.xlsx +0 -0
- scitex/scholar/data/impact_factor/JCR_IF_2024.db +0 -0
- scitex/scholar/data/impact_factor/JCR_IF_2024.xlsx +0 -0
- scitex/scholar/data/impact_factor/JCR_IF_2024_v01.db +0 -0
- scitex/scholar/data/impact_factor.db +0 -0
- scitex/scholar/examples/SUGGESTIONS.md +0 -865
- scitex/scholar/examples/dev.py +0 -38
- scitex-2.14.0.dist-info/METADATA +0 -1238
- /scitex/{gen → context}/_detect_environment.py +0 -0
- /scitex/{gen → context}/_get_notebook_path.py +0 -0
- /scitex/{gen/_shell.py → sh/_shell_legacy.py} +0 -0
- {scitex-2.14.0.dist-info → scitex-2.15.2.dist-info}/WHEEL +0 -0
- {scitex-2.14.0.dist-info → scitex-2.15.2.dist-info}/entry_points.txt +0 -0
- {scitex-2.14.0.dist-info → scitex-2.15.2.dist-info}/licenses/LICENSE +0 -0
scitex/diagram/_mcp/handlers.py
DELETED
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# Timestamp: 2026-01-08
|
|
3
|
-
# File: src/scitex/diagram/_mcp.handlers.py
|
|
4
|
-
# ----------------------------------------
|
|
5
|
-
|
|
6
|
-
"""
|
|
7
|
-
MCP Handler implementations for SciTeX diagram module.
|
|
8
|
-
|
|
9
|
-
Provides async handlers for paper-optimized diagram generation.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
from __future__ import annotations
|
|
13
|
-
|
|
14
|
-
import asyncio
|
|
15
|
-
from typing import Optional
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
async def create_diagram_handler(
|
|
19
|
-
spec_path: Optional[str] = None,
|
|
20
|
-
spec_dict: Optional[dict] = None,
|
|
21
|
-
) -> dict:
|
|
22
|
-
"""
|
|
23
|
-
Create a diagram from specification.
|
|
24
|
-
|
|
25
|
-
Parameters
|
|
26
|
-
----------
|
|
27
|
-
spec_path : str, optional
|
|
28
|
-
Path to YAML spec file
|
|
29
|
-
spec_dict : dict, optional
|
|
30
|
-
Spec as dictionary
|
|
31
|
-
|
|
32
|
-
Returns
|
|
33
|
-
-------
|
|
34
|
-
dict
|
|
35
|
-
Success status and diagram info
|
|
36
|
-
"""
|
|
37
|
-
try:
|
|
38
|
-
from scitex.diagram import Diagram
|
|
39
|
-
|
|
40
|
-
if spec_path:
|
|
41
|
-
loop = asyncio.get_event_loop()
|
|
42
|
-
diagram = await loop.run_in_executor(
|
|
43
|
-
None,
|
|
44
|
-
lambda: Diagram.from_yaml(spec_path),
|
|
45
|
-
)
|
|
46
|
-
elif spec_dict:
|
|
47
|
-
diagram = Diagram(spec_dict)
|
|
48
|
-
else:
|
|
49
|
-
return {
|
|
50
|
-
"success": False,
|
|
51
|
-
"error": "Either spec_path or spec_dict must be provided",
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
# Get diagram info
|
|
55
|
-
spec = diagram.spec if hasattr(diagram, "spec") else {}
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
"success": True,
|
|
59
|
-
"diagram_type": spec.get("type", "unknown"),
|
|
60
|
-
"node_count": len(spec.get("nodes", [])),
|
|
61
|
-
"edge_count": len(spec.get("edges", [])),
|
|
62
|
-
"message": "Diagram created successfully",
|
|
63
|
-
}
|
|
64
|
-
except Exception as e:
|
|
65
|
-
return {
|
|
66
|
-
"success": False,
|
|
67
|
-
"error": str(e),
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
async def compile_mermaid_handler(
|
|
72
|
-
spec_path: Optional[str] = None,
|
|
73
|
-
output_path: Optional[str] = None,
|
|
74
|
-
spec_dict: Optional[dict] = None,
|
|
75
|
-
) -> dict:
|
|
76
|
-
"""
|
|
77
|
-
Compile diagram to Mermaid format.
|
|
78
|
-
|
|
79
|
-
Parameters
|
|
80
|
-
----------
|
|
81
|
-
spec_path : str, optional
|
|
82
|
-
Path to YAML spec file
|
|
83
|
-
output_path : str, optional
|
|
84
|
-
Output .mmd file path
|
|
85
|
-
spec_dict : dict, optional
|
|
86
|
-
Spec as dictionary
|
|
87
|
-
|
|
88
|
-
Returns
|
|
89
|
-
-------
|
|
90
|
-
dict
|
|
91
|
-
Success status and Mermaid output
|
|
92
|
-
"""
|
|
93
|
-
try:
|
|
94
|
-
from scitex.diagram import Diagram, compile_to_mermaid
|
|
95
|
-
|
|
96
|
-
if spec_path:
|
|
97
|
-
loop = asyncio.get_event_loop()
|
|
98
|
-
diagram = await loop.run_in_executor(
|
|
99
|
-
None,
|
|
100
|
-
lambda: Diagram.from_yaml(spec_path),
|
|
101
|
-
)
|
|
102
|
-
elif spec_dict:
|
|
103
|
-
diagram = Diagram(spec_dict)
|
|
104
|
-
else:
|
|
105
|
-
return {
|
|
106
|
-
"success": False,
|
|
107
|
-
"error": "Either spec_path or spec_dict must be provided",
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
# Compile to Mermaid
|
|
111
|
-
loop = asyncio.get_event_loop()
|
|
112
|
-
mermaid_code = await loop.run_in_executor(
|
|
113
|
-
None,
|
|
114
|
-
lambda: compile_to_mermaid(diagram.spec),
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
# Save if output path provided
|
|
118
|
-
if output_path:
|
|
119
|
-
from pathlib import Path
|
|
120
|
-
|
|
121
|
-
Path(output_path).write_text(mermaid_code)
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
"success": True,
|
|
125
|
-
"mermaid_code": mermaid_code,
|
|
126
|
-
"output_path": output_path,
|
|
127
|
-
"message": f"Compiled to Mermaid{f' and saved to {output_path}' if output_path else ''}",
|
|
128
|
-
}
|
|
129
|
-
except Exception as e:
|
|
130
|
-
return {
|
|
131
|
-
"success": False,
|
|
132
|
-
"error": str(e),
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
async def compile_graphviz_handler(
|
|
137
|
-
spec_path: Optional[str] = None,
|
|
138
|
-
output_path: Optional[str] = None,
|
|
139
|
-
spec_dict: Optional[dict] = None,
|
|
140
|
-
) -> dict:
|
|
141
|
-
"""
|
|
142
|
-
Compile diagram to Graphviz DOT format.
|
|
143
|
-
|
|
144
|
-
Parameters
|
|
145
|
-
----------
|
|
146
|
-
spec_path : str, optional
|
|
147
|
-
Path to YAML spec file
|
|
148
|
-
output_path : str, optional
|
|
149
|
-
Output .dot file path
|
|
150
|
-
spec_dict : dict, optional
|
|
151
|
-
Spec as dictionary
|
|
152
|
-
|
|
153
|
-
Returns
|
|
154
|
-
-------
|
|
155
|
-
dict
|
|
156
|
-
Success status and DOT output
|
|
157
|
-
"""
|
|
158
|
-
try:
|
|
159
|
-
from scitex.diagram import Diagram, compile_to_graphviz
|
|
160
|
-
|
|
161
|
-
if spec_path:
|
|
162
|
-
loop = asyncio.get_event_loop()
|
|
163
|
-
diagram = await loop.run_in_executor(
|
|
164
|
-
None,
|
|
165
|
-
lambda: Diagram.from_yaml(spec_path),
|
|
166
|
-
)
|
|
167
|
-
elif spec_dict:
|
|
168
|
-
diagram = Diagram(spec_dict)
|
|
169
|
-
else:
|
|
170
|
-
return {
|
|
171
|
-
"success": False,
|
|
172
|
-
"error": "Either spec_path or spec_dict must be provided",
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
# Compile to Graphviz
|
|
176
|
-
loop = asyncio.get_event_loop()
|
|
177
|
-
dot_code = await loop.run_in_executor(
|
|
178
|
-
None,
|
|
179
|
-
lambda: compile_to_graphviz(diagram.spec),
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
# Save if output path provided
|
|
183
|
-
if output_path:
|
|
184
|
-
from pathlib import Path
|
|
185
|
-
|
|
186
|
-
Path(output_path).write_text(dot_code)
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
"success": True,
|
|
190
|
-
"dot_code": dot_code,
|
|
191
|
-
"output_path": output_path,
|
|
192
|
-
"message": f"Compiled to Graphviz{f' and saved to {output_path}' if output_path else ''}",
|
|
193
|
-
}
|
|
194
|
-
except Exception as e:
|
|
195
|
-
return {
|
|
196
|
-
"success": False,
|
|
197
|
-
"error": str(e),
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
async def list_presets_handler() -> dict:
|
|
202
|
-
"""
|
|
203
|
-
List available diagram presets.
|
|
204
|
-
|
|
205
|
-
Returns
|
|
206
|
-
-------
|
|
207
|
-
dict
|
|
208
|
-
Success status and preset list
|
|
209
|
-
"""
|
|
210
|
-
try:
|
|
211
|
-
presets = [
|
|
212
|
-
{
|
|
213
|
-
"name": "workflow",
|
|
214
|
-
"description": "Linear workflow diagrams (step1 → step2 → step3)",
|
|
215
|
-
"use_case": "Methods section, data processing pipelines",
|
|
216
|
-
"direction": "left-to-right",
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
"name": "decision",
|
|
220
|
-
"description": "Decision tree/flowchart diagrams",
|
|
221
|
-
"use_case": "Algorithm flowcharts, decision processes",
|
|
222
|
-
"direction": "top-to-bottom",
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
"name": "pipeline",
|
|
226
|
-
"description": "Data pipeline with parallel branches",
|
|
227
|
-
"use_case": "Complex data flows, parallel processing",
|
|
228
|
-
"direction": "left-to-right",
|
|
229
|
-
},
|
|
230
|
-
]
|
|
231
|
-
|
|
232
|
-
return {
|
|
233
|
-
"success": True,
|
|
234
|
-
"count": len(presets),
|
|
235
|
-
"presets": presets,
|
|
236
|
-
}
|
|
237
|
-
except Exception as e:
|
|
238
|
-
return {
|
|
239
|
-
"success": False,
|
|
240
|
-
"error": str(e),
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
async def get_preset_handler(preset_name: str) -> dict:
|
|
245
|
-
"""
|
|
246
|
-
Get a specific preset configuration.
|
|
247
|
-
|
|
248
|
-
Parameters
|
|
249
|
-
----------
|
|
250
|
-
preset_name : str
|
|
251
|
-
Preset name (workflow, decision, pipeline)
|
|
252
|
-
|
|
253
|
-
Returns
|
|
254
|
-
-------
|
|
255
|
-
dict
|
|
256
|
-
Success status and preset config
|
|
257
|
-
"""
|
|
258
|
-
try:
|
|
259
|
-
from scitex.diagram import DECISION_PRESET, PIPELINE_PRESET, WORKFLOW_PRESET
|
|
260
|
-
|
|
261
|
-
presets = {
|
|
262
|
-
"workflow": WORKFLOW_PRESET,
|
|
263
|
-
"decision": DECISION_PRESET,
|
|
264
|
-
"pipeline": PIPELINE_PRESET,
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if preset_name not in presets:
|
|
268
|
-
return {
|
|
269
|
-
"success": False,
|
|
270
|
-
"error": f"Unknown preset: {preset_name}",
|
|
271
|
-
"available": list(presets.keys()),
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
preset = presets[preset_name]
|
|
275
|
-
|
|
276
|
-
return {
|
|
277
|
-
"success": True,
|
|
278
|
-
"preset_name": preset_name,
|
|
279
|
-
"config": preset,
|
|
280
|
-
}
|
|
281
|
-
except Exception as e:
|
|
282
|
-
return {
|
|
283
|
-
"success": False,
|
|
284
|
-
"error": str(e),
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
async def split_diagram_handler(
|
|
289
|
-
spec_path: str,
|
|
290
|
-
strategy: str = "horizontal",
|
|
291
|
-
max_nodes_per_part: int = 10,
|
|
292
|
-
) -> dict:
|
|
293
|
-
"""
|
|
294
|
-
Split a large diagram into smaller parts.
|
|
295
|
-
|
|
296
|
-
Parameters
|
|
297
|
-
----------
|
|
298
|
-
spec_path : str
|
|
299
|
-
Path to YAML spec file
|
|
300
|
-
strategy : str
|
|
301
|
-
Split strategy (horizontal, vertical, semantic)
|
|
302
|
-
max_nodes_per_part : int
|
|
303
|
-
Max nodes per part
|
|
304
|
-
|
|
305
|
-
Returns
|
|
306
|
-
-------
|
|
307
|
-
dict
|
|
308
|
-
Success status and split results
|
|
309
|
-
"""
|
|
310
|
-
try:
|
|
311
|
-
from scitex.diagram import Diagram, SplitConfig, SplitStrategy, split_diagram
|
|
312
|
-
|
|
313
|
-
# Map strategy string to enum
|
|
314
|
-
strategy_map = {
|
|
315
|
-
"horizontal": SplitStrategy.HORIZONTAL,
|
|
316
|
-
"vertical": SplitStrategy.VERTICAL,
|
|
317
|
-
"semantic": SplitStrategy.SEMANTIC,
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if strategy not in strategy_map:
|
|
321
|
-
return {
|
|
322
|
-
"success": False,
|
|
323
|
-
"error": f"Unknown strategy: {strategy}",
|
|
324
|
-
"available": list(strategy_map.keys()),
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
loop = asyncio.get_event_loop()
|
|
328
|
-
diagram = await loop.run_in_executor(
|
|
329
|
-
None,
|
|
330
|
-
lambda: Diagram.from_yaml(spec_path),
|
|
331
|
-
)
|
|
332
|
-
|
|
333
|
-
config = SplitConfig(
|
|
334
|
-
strategy=strategy_map[strategy],
|
|
335
|
-
max_nodes_per_part=max_nodes_per_part,
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
result = await loop.run_in_executor(
|
|
339
|
-
None,
|
|
340
|
-
lambda: split_diagram(diagram.spec, config),
|
|
341
|
-
)
|
|
342
|
-
|
|
343
|
-
return {
|
|
344
|
-
"success": True,
|
|
345
|
-
"strategy": strategy,
|
|
346
|
-
"parts_count": len(result.parts) if hasattr(result, "parts") else 0,
|
|
347
|
-
"result": str(result),
|
|
348
|
-
}
|
|
349
|
-
except Exception as e:
|
|
350
|
-
return {
|
|
351
|
-
"success": False,
|
|
352
|
-
"error": str(e),
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
async def get_paper_modes_handler() -> dict:
|
|
357
|
-
"""
|
|
358
|
-
Get available paper layout modes.
|
|
359
|
-
|
|
360
|
-
Returns
|
|
361
|
-
-------
|
|
362
|
-
dict
|
|
363
|
-
Success status and paper modes
|
|
364
|
-
"""
|
|
365
|
-
try:
|
|
366
|
-
from scitex.diagram import PaperMode
|
|
367
|
-
|
|
368
|
-
modes = []
|
|
369
|
-
for mode in PaperMode:
|
|
370
|
-
modes.append(
|
|
371
|
-
{
|
|
372
|
-
"name": mode.name,
|
|
373
|
-
"value": mode.value,
|
|
374
|
-
}
|
|
375
|
-
)
|
|
376
|
-
|
|
377
|
-
return {
|
|
378
|
-
"success": True,
|
|
379
|
-
"count": len(modes),
|
|
380
|
-
"modes": modes,
|
|
381
|
-
"description": "Paper modes control diagram sizing for publication layouts",
|
|
382
|
-
}
|
|
383
|
-
except Exception as e:
|
|
384
|
-
return {
|
|
385
|
-
"success": False,
|
|
386
|
-
"error": str(e),
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
__all__ = [
|
|
391
|
-
"create_diagram_handler",
|
|
392
|
-
"compile_mermaid_handler",
|
|
393
|
-
"compile_graphviz_handler",
|
|
394
|
-
"list_presets_handler",
|
|
395
|
-
"get_preset_handler",
|
|
396
|
-
"split_diagram_handler",
|
|
397
|
-
"get_paper_modes_handler",
|
|
398
|
-
]
|
|
399
|
-
|
|
400
|
-
# EOF
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# Timestamp: 2026-01-08
|
|
3
|
-
# File: src/scitex/diagram/_mcp.tool_schemas.py
|
|
4
|
-
# ----------------------------------------
|
|
5
|
-
|
|
6
|
-
"""
|
|
7
|
-
MCP Tool schemas for SciTeX diagram module.
|
|
8
|
-
|
|
9
|
-
Defines tools for paper-optimized diagram generation:
|
|
10
|
-
- create_diagram: Create diagram from YAML spec
|
|
11
|
-
- compile_mermaid: Export to Mermaid format
|
|
12
|
-
- compile_graphviz: Export to Graphviz DOT format
|
|
13
|
-
- list_presets: List available diagram presets
|
|
14
|
-
- apply_preset: Apply workflow/decision/pipeline preset
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
from __future__ import annotations
|
|
18
|
-
|
|
19
|
-
import mcp.types as types
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def get_tool_schemas() -> list[types.Tool]:
|
|
23
|
-
"""Return list of available MCP tools for diagram operations."""
|
|
24
|
-
return [
|
|
25
|
-
# Create diagram from YAML
|
|
26
|
-
types.Tool(
|
|
27
|
-
name="create_diagram",
|
|
28
|
-
description="Create a diagram from a YAML specification file or dictionary",
|
|
29
|
-
inputSchema={
|
|
30
|
-
"type": "object",
|
|
31
|
-
"properties": {
|
|
32
|
-
"spec_path": {
|
|
33
|
-
"type": "string",
|
|
34
|
-
"description": "Path to YAML specification file",
|
|
35
|
-
},
|
|
36
|
-
"spec_dict": {
|
|
37
|
-
"type": "object",
|
|
38
|
-
"description": "Diagram specification as dictionary (alternative to spec_path)",
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
"required": [],
|
|
42
|
-
},
|
|
43
|
-
),
|
|
44
|
-
# Compile to Mermaid
|
|
45
|
-
types.Tool(
|
|
46
|
-
name="compile_mermaid",
|
|
47
|
-
description="Compile diagram specification to Mermaid format",
|
|
48
|
-
inputSchema={
|
|
49
|
-
"type": "object",
|
|
50
|
-
"properties": {
|
|
51
|
-
"spec_path": {
|
|
52
|
-
"type": "string",
|
|
53
|
-
"description": "Path to YAML specification file",
|
|
54
|
-
},
|
|
55
|
-
"output_path": {
|
|
56
|
-
"type": "string",
|
|
57
|
-
"description": "Output file path for .mmd file",
|
|
58
|
-
},
|
|
59
|
-
"spec_dict": {
|
|
60
|
-
"type": "object",
|
|
61
|
-
"description": "Diagram specification as dictionary (alternative to spec_path)",
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
"required": [],
|
|
65
|
-
},
|
|
66
|
-
),
|
|
67
|
-
# Compile to Graphviz
|
|
68
|
-
types.Tool(
|
|
69
|
-
name="compile_graphviz",
|
|
70
|
-
description="Compile diagram specification to Graphviz DOT format",
|
|
71
|
-
inputSchema={
|
|
72
|
-
"type": "object",
|
|
73
|
-
"properties": {
|
|
74
|
-
"spec_path": {
|
|
75
|
-
"type": "string",
|
|
76
|
-
"description": "Path to YAML specification file",
|
|
77
|
-
},
|
|
78
|
-
"output_path": {
|
|
79
|
-
"type": "string",
|
|
80
|
-
"description": "Output file path for .dot file",
|
|
81
|
-
},
|
|
82
|
-
"spec_dict": {
|
|
83
|
-
"type": "object",
|
|
84
|
-
"description": "Diagram specification as dictionary (alternative to spec_path)",
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
"required": [],
|
|
88
|
-
},
|
|
89
|
-
),
|
|
90
|
-
# List presets
|
|
91
|
-
types.Tool(
|
|
92
|
-
name="list_presets",
|
|
93
|
-
description="List available diagram presets (workflow, decision, pipeline)",
|
|
94
|
-
inputSchema={
|
|
95
|
-
"type": "object",
|
|
96
|
-
"properties": {},
|
|
97
|
-
"required": [],
|
|
98
|
-
},
|
|
99
|
-
),
|
|
100
|
-
# Get preset
|
|
101
|
-
types.Tool(
|
|
102
|
-
name="get_preset",
|
|
103
|
-
description="Get a diagram preset configuration by name",
|
|
104
|
-
inputSchema={
|
|
105
|
-
"type": "object",
|
|
106
|
-
"properties": {
|
|
107
|
-
"preset_name": {
|
|
108
|
-
"type": "string",
|
|
109
|
-
"description": "Preset name",
|
|
110
|
-
"enum": ["workflow", "decision", "pipeline"],
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
"required": ["preset_name"],
|
|
114
|
-
},
|
|
115
|
-
),
|
|
116
|
-
# Split diagram
|
|
117
|
-
types.Tool(
|
|
118
|
-
name="split_diagram",
|
|
119
|
-
description="Split a large diagram into smaller parts for multi-column layouts",
|
|
120
|
-
inputSchema={
|
|
121
|
-
"type": "object",
|
|
122
|
-
"properties": {
|
|
123
|
-
"spec_path": {
|
|
124
|
-
"type": "string",
|
|
125
|
-
"description": "Path to YAML specification file",
|
|
126
|
-
},
|
|
127
|
-
"strategy": {
|
|
128
|
-
"type": "string",
|
|
129
|
-
"description": "Split strategy",
|
|
130
|
-
"enum": ["horizontal", "vertical", "semantic"],
|
|
131
|
-
"default": "horizontal",
|
|
132
|
-
},
|
|
133
|
-
"max_nodes_per_part": {
|
|
134
|
-
"type": "integer",
|
|
135
|
-
"description": "Maximum nodes per split part",
|
|
136
|
-
"default": 10,
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
"required": ["spec_path"],
|
|
140
|
-
},
|
|
141
|
-
),
|
|
142
|
-
# Get paper modes
|
|
143
|
-
types.Tool(
|
|
144
|
-
name="get_paper_modes",
|
|
145
|
-
description="Get available paper layout modes and their constraints",
|
|
146
|
-
inputSchema={
|
|
147
|
-
"type": "object",
|
|
148
|
-
"properties": {},
|
|
149
|
-
"required": [],
|
|
150
|
-
},
|
|
151
|
-
),
|
|
152
|
-
]
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
__all__ = ["get_tool_schemas"]
|
|
156
|
-
|
|
157
|
-
# EOF
|