@wentorai/research-plugins 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +204 -0
- package/curated/analysis/README.md +64 -0
- package/curated/domains/README.md +104 -0
- package/curated/literature/README.md +53 -0
- package/curated/research/README.md +62 -0
- package/curated/tools/README.md +87 -0
- package/curated/writing/README.md +61 -0
- package/index.ts +39 -0
- package/mcp-configs/academic-db/ChatSpatial.json +17 -0
- package/mcp-configs/academic-db/academia-mcp.json +17 -0
- package/mcp-configs/academic-db/academic-paper-explorer.json +17 -0
- package/mcp-configs/academic-db/academic-search-mcp-server.json +17 -0
- package/mcp-configs/academic-db/agentinterviews-mcp.json +17 -0
- package/mcp-configs/academic-db/all-in-mcp.json +17 -0
- package/mcp-configs/academic-db/apple-health-mcp.json +17 -0
- package/mcp-configs/academic-db/arxiv-latex-mcp.json +17 -0
- package/mcp-configs/academic-db/arxiv-mcp-server.json +17 -0
- package/mcp-configs/academic-db/bgpt-mcp.json +17 -0
- package/mcp-configs/academic-db/biomcp.json +17 -0
- package/mcp-configs/academic-db/biothings-mcp.json +17 -0
- package/mcp-configs/academic-db/catalysishub-mcp-server.json +17 -0
- package/mcp-configs/academic-db/clinicaltrialsgov-mcp-server.json +17 -0
- package/mcp-configs/academic-db/deep-research-mcp.json +17 -0
- package/mcp-configs/academic-db/dicom-mcp.json +17 -0
- package/mcp-configs/academic-db/enrichr-mcp-server.json +17 -0
- package/mcp-configs/academic-db/fec-mcp-server.json +17 -0
- package/mcp-configs/academic-db/fhir-mcp-server-themomentum.json +17 -0
- package/mcp-configs/academic-db/fhir-mcp.json +19 -0
- package/mcp-configs/academic-db/gget-mcp.json +17 -0
- package/mcp-configs/academic-db/google-researcher-mcp.json +17 -0
- package/mcp-configs/academic-db/idea-reality-mcp.json +17 -0
- package/mcp-configs/academic-db/legiscan-mcp.json +19 -0
- package/mcp-configs/academic-db/lex.json +17 -0
- package/mcp-configs/ai-platform/Adaptive-Graph-of-Thoughts-MCP-server.json +17 -0
- package/mcp-configs/ai-platform/ai-counsel.json +17 -0
- package/mcp-configs/ai-platform/atlas-mcp-server.json +17 -0
- package/mcp-configs/ai-platform/counsel-mcp.json +17 -0
- package/mcp-configs/ai-platform/cross-llm-mcp.json +17 -0
- package/mcp-configs/ai-platform/gptr-mcp.json +17 -0
- package/mcp-configs/browser/decipher-research-agent.json +17 -0
- package/mcp-configs/browser/deep-research.json +17 -0
- package/mcp-configs/browser/everything-claude-code.json +17 -0
- package/mcp-configs/browser/gpt-researcher.json +17 -0
- package/mcp-configs/browser/heurist-agent-framework.json +17 -0
- package/mcp-configs/data-platform/4everland-hosting-mcp.json +17 -0
- package/mcp-configs/data-platform/context-keeper.json +17 -0
- package/mcp-configs/data-platform/context7.json +19 -0
- package/mcp-configs/data-platform/contextstream-mcp.json +17 -0
- package/mcp-configs/data-platform/email-mcp.json +17 -0
- package/mcp-configs/note-knowledge/ApeRAG.json +17 -0
- package/mcp-configs/note-knowledge/In-Memoria.json +17 -0
- package/mcp-configs/note-knowledge/agent-memory.json +17 -0
- package/mcp-configs/note-knowledge/aimemo.json +17 -0
- package/mcp-configs/note-knowledge/biel-mcp.json +19 -0
- package/mcp-configs/note-knowledge/cognee.json +17 -0
- package/mcp-configs/note-knowledge/context-awesome.json +17 -0
- package/mcp-configs/note-knowledge/context-mcp.json +17 -0
- package/mcp-configs/note-knowledge/conversation-handoff-mcp.json +17 -0
- package/mcp-configs/note-knowledge/cortex.json +17 -0
- package/mcp-configs/note-knowledge/devrag.json +17 -0
- package/mcp-configs/note-knowledge/easy-obsidian-mcp.json +17 -0
- package/mcp-configs/note-knowledge/engram.json +17 -0
- package/mcp-configs/note-knowledge/gnosis-mcp.json +17 -0
- package/mcp-configs/note-knowledge/graphlit-mcp-server.json +19 -0
- package/mcp-configs/reference-mgr/arxiv-cli.json +17 -0
- package/mcp-configs/reference-mgr/arxiv-search-mcp.json +17 -0
- package/mcp-configs/reference-mgr/chiken.json +17 -0
- package/mcp-configs/reference-mgr/claude-scholar.json +17 -0
- package/mcp-configs/reference-mgr/devonthink-mcp.json +17 -0
- package/mcp-configs/registry.json +447 -0
- package/openclaw.plugin.json +21 -0
- package/package.json +61 -0
- package/skills/analysis/dataviz/color-accessibility-guide/SKILL.md +230 -0
- package/skills/analysis/dataviz/geospatial-viz-guide/SKILL.md +218 -0
- package/skills/analysis/dataviz/interactive-viz-guide/SKILL.md +287 -0
- package/skills/analysis/dataviz/network-visualization-guide/SKILL.md +195 -0
- package/skills/analysis/dataviz/publication-figures-guide/SKILL.md +238 -0
- package/skills/analysis/dataviz/python-dataviz-guide/SKILL.md +195 -0
- package/skills/analysis/econometrics/causal-inference-guide/SKILL.md +197 -0
- package/skills/analysis/econometrics/iv-regression-guide/SKILL.md +198 -0
- package/skills/analysis/econometrics/panel-data-guide/SKILL.md +274 -0
- package/skills/analysis/econometrics/robustness-checks/SKILL.md +250 -0
- package/skills/analysis/econometrics/stata-regression/SKILL.md +117 -0
- package/skills/analysis/econometrics/time-series-guide/SKILL.md +235 -0
- package/skills/analysis/statistics/bayesian-statistics-guide/SKILL.md +221 -0
- package/skills/analysis/statistics/hypothesis-testing-guide/SKILL.md +210 -0
- package/skills/analysis/statistics/meta-analysis-guide/SKILL.md +206 -0
- package/skills/analysis/statistics/nonparametric-tests-guide/SKILL.md +221 -0
- package/skills/analysis/statistics/power-analysis-guide/SKILL.md +240 -0
- package/skills/analysis/statistics/sem-guide/SKILL.md +231 -0
- package/skills/analysis/statistics/survival-analysis-guide/SKILL.md +195 -0
- package/skills/analysis/wrangling/missing-data-handling/SKILL.md +224 -0
- package/skills/analysis/wrangling/pandas-data-wrangling/SKILL.md +242 -0
- package/skills/analysis/wrangling/questionnaire-design-guide/SKILL.md +234 -0
- package/skills/analysis/wrangling/text-mining-guide/SKILL.md +225 -0
- package/skills/domains/ai-ml/computer-vision-guide/SKILL.md +213 -0
- package/skills/domains/ai-ml/deep-learning-papers-guide/SKILL.md +200 -0
- package/skills/domains/ai-ml/llm-evaluation-guide/SKILL.md +194 -0
- package/skills/domains/ai-ml/prompt-engineering-research/SKILL.md +233 -0
- package/skills/domains/ai-ml/reinforcement-learning-guide/SKILL.md +254 -0
- package/skills/domains/ai-ml/transformer-architecture-guide/SKILL.md +233 -0
- package/skills/domains/biomedical/clinical-research-guide/SKILL.md +232 -0
- package/skills/domains/biomedical/clinicaltrials-api/SKILL.md +177 -0
- package/skills/domains/biomedical/epidemiology-guide/SKILL.md +200 -0
- package/skills/domains/biomedical/genomics-analysis-guide/SKILL.md +270 -0
- package/skills/domains/business/market-analysis-guide/SKILL.md +112 -0
- package/skills/domains/business/strategic-management-guide/SKILL.md +154 -0
- package/skills/domains/chemistry/computational-chemistry-guide/SKILL.md +266 -0
- package/skills/domains/chemistry/retrosynthesis-guide/SKILL.md +215 -0
- package/skills/domains/cs/algorithms-complexity-guide/SKILL.md +194 -0
- package/skills/domains/cs/dblp-api/SKILL.md +129 -0
- package/skills/domains/cs/software-engineering-research/SKILL.md +218 -0
- package/skills/domains/ecology/biodiversity-data-guide/SKILL.md +296 -0
- package/skills/domains/ecology/conservation-biology-guide/SKILL.md +198 -0
- package/skills/domains/ecology/gbif-api/SKILL.md +158 -0
- package/skills/domains/ecology/inaturalist-api/SKILL.md +173 -0
- package/skills/domains/economics/behavioral-economics-guide/SKILL.md +239 -0
- package/skills/domains/economics/development-economics-guide/SKILL.md +181 -0
- package/skills/domains/economics/fred-api/SKILL.md +189 -0
- package/skills/domains/education/curriculum-design-guide/SKILL.md +144 -0
- package/skills/domains/education/learning-science-guide/SKILL.md +150 -0
- package/skills/domains/finance/financial-data-analysis/SKILL.md +152 -0
- package/skills/domains/finance/quantitative-finance-guide/SKILL.md +151 -0
- package/skills/domains/geoscience/climate-science-guide/SKILL.md +158 -0
- package/skills/domains/geoscience/gis-remote-sensing-guide/SKILL.md +129 -0
- package/skills/domains/humanities/digital-humanities-guide/SKILL.md +181 -0
- package/skills/domains/humanities/philosophy-research-guide/SKILL.md +148 -0
- package/skills/domains/law/courtlistener-api/SKILL.md +213 -0
- package/skills/domains/law/legal-research-guide/SKILL.md +250 -0
- package/skills/domains/math/linear-algebra-applications/SKILL.md +227 -0
- package/skills/domains/math/numerical-methods-guide/SKILL.md +236 -0
- package/skills/domains/math/oeis-api/SKILL.md +158 -0
- package/skills/domains/pharma/clinical-pharmacology-guide/SKILL.md +165 -0
- package/skills/domains/pharma/drug-development-guide/SKILL.md +177 -0
- package/skills/domains/physics/computational-physics-guide/SKILL.md +300 -0
- package/skills/domains/physics/nasa-ads-api/SKILL.md +150 -0
- package/skills/domains/physics/quantum-computing-guide/SKILL.md +234 -0
- package/skills/domains/social-science/social-research-methods/SKILL.md +194 -0
- package/skills/domains/social-science/survey-research-guide/SKILL.md +182 -0
- package/skills/literature/discovery/citation-alert-guide/SKILL.md +154 -0
- package/skills/literature/discovery/conference-proceedings-guide/SKILL.md +142 -0
- package/skills/literature/discovery/literature-mapping-guide/SKILL.md +175 -0
- package/skills/literature/discovery/paper-tracking-guide/SKILL.md +211 -0
- package/skills/literature/discovery/rss-paper-feeds/SKILL.md +214 -0
- package/skills/literature/discovery/semantic-scholar-recs-guide/SKILL.md +164 -0
- package/skills/literature/fulltext/doaj-api/SKILL.md +120 -0
- package/skills/literature/fulltext/interlibrary-loan-guide/SKILL.md +163 -0
- package/skills/literature/fulltext/open-access-guide/SKILL.md +183 -0
- package/skills/literature/fulltext/pmc-oai-api/SKILL.md +184 -0
- package/skills/literature/fulltext/preprint-servers-guide/SKILL.md +128 -0
- package/skills/literature/fulltext/repository-harvesting-guide/SKILL.md +207 -0
- package/skills/literature/fulltext/unpaywall-api/SKILL.md +113 -0
- package/skills/literature/metadata/altmetrics-guide/SKILL.md +132 -0
- package/skills/literature/metadata/citation-network-guide/SKILL.md +236 -0
- package/skills/literature/metadata/crossref-api/SKILL.md +133 -0
- package/skills/literature/metadata/datacite-api/SKILL.md +126 -0
- package/skills/literature/metadata/doi-resolution-guide/SKILL.md +168 -0
- package/skills/literature/metadata/h-index-guide/SKILL.md +183 -0
- package/skills/literature/metadata/journal-metrics-guide/SKILL.md +188 -0
- package/skills/literature/metadata/opencitations-api/SKILL.md +128 -0
- package/skills/literature/metadata/orcid-api/SKILL.md +136 -0
- package/skills/literature/metadata/orcid-integration-guide/SKILL.md +178 -0
- package/skills/literature/search/arxiv-api/SKILL.md +95 -0
- package/skills/literature/search/biorxiv-api/SKILL.md +123 -0
- package/skills/literature/search/boolean-search-guide/SKILL.md +199 -0
- package/skills/literature/search/citation-chaining-guide/SKILL.md +148 -0
- package/skills/literature/search/database-comparison-guide/SKILL.md +100 -0
- package/skills/literature/search/europe-pmc-api/SKILL.md +120 -0
- package/skills/literature/search/google-scholar-guide/SKILL.md +182 -0
- package/skills/literature/search/mesh-terms-guide/SKILL.md +164 -0
- package/skills/literature/search/openalex-api/SKILL.md +134 -0
- package/skills/literature/search/pubmed-api/SKILL.md +130 -0
- package/skills/literature/search/scientify-literature-survey/SKILL.md +203 -0
- package/skills/literature/search/semantic-scholar-api/SKILL.md +134 -0
- package/skills/literature/search/systematic-search-strategy/SKILL.md +214 -0
- package/skills/research/automation/ai-scientist-guide/SKILL.md +228 -0
- package/skills/research/automation/data-collection-automation/SKILL.md +248 -0
- package/skills/research/automation/research-workflow-automation/SKILL.md +266 -0
- package/skills/research/deep-research/meta-synthesis-guide/SKILL.md +174 -0
- package/skills/research/deep-research/research-cog/SKILL.md +153 -0
- package/skills/research/deep-research/scoping-review-guide/SKILL.md +217 -0
- package/skills/research/deep-research/systematic-review-guide/SKILL.md +250 -0
- package/skills/research/funding/figshare-api/SKILL.md +163 -0
- package/skills/research/funding/grant-writing-guide/SKILL.md +233 -0
- package/skills/research/funding/nsf-grant-guide/SKILL.md +206 -0
- package/skills/research/funding/open-science-guide/SKILL.md +255 -0
- package/skills/research/funding/zenodo-api/SKILL.md +174 -0
- package/skills/research/methodology/action-research-guide/SKILL.md +201 -0
- package/skills/research/methodology/experimental-design-guide/SKILL.md +236 -0
- package/skills/research/methodology/grad-school-guide/SKILL.md +182 -0
- package/skills/research/methodology/grounded-theory-guide/SKILL.md +171 -0
- package/skills/research/methodology/mixed-methods-guide/SKILL.md +208 -0
- package/skills/research/methodology/qualitative-research-guide/SKILL.md +234 -0
- package/skills/research/methodology/scientify-idea-generation/SKILL.md +222 -0
- package/skills/research/paper-review/paper-reading-assistant/SKILL.md +266 -0
- package/skills/research/paper-review/peer-review-guide/SKILL.md +227 -0
- package/skills/research/paper-review/rebuttal-writing-guide/SKILL.md +185 -0
- package/skills/research/paper-review/scientify-write-review-paper/SKILL.md +209 -0
- package/skills/tools/code-exec/jupyter-notebook-guide/SKILL.md +178 -0
- package/skills/tools/code-exec/python-reproducibility-guide/SKILL.md +341 -0
- package/skills/tools/code-exec/r-reproducibility-guide/SKILL.md +236 -0
- package/skills/tools/code-exec/sandbox-execution-guide/SKILL.md +221 -0
- package/skills/tools/diagram/mermaid-diagram-guide/SKILL.md +269 -0
- package/skills/tools/diagram/plantuml-guide/SKILL.md +397 -0
- package/skills/tools/diagram/scientific-illustration-guide/SKILL.md +225 -0
- package/skills/tools/document/anystyle-api/SKILL.md +199 -0
- package/skills/tools/document/grobid-pdf-parsing/SKILL.md +294 -0
- package/skills/tools/document/markdown-academic-guide/SKILL.md +217 -0
- package/skills/tools/document/pdf-extraction-guide/SKILL.md +321 -0
- package/skills/tools/knowledge-graph/knowledge-graph-construction/SKILL.md +306 -0
- package/skills/tools/knowledge-graph/ontology-design-guide/SKILL.md +214 -0
- package/skills/tools/knowledge-graph/rag-methodology-guide/SKILL.md +325 -0
- package/skills/tools/ocr-translate/formula-recognition-guide/SKILL.md +367 -0
- package/skills/tools/ocr-translate/handwriting-recognition-guide/SKILL.md +211 -0
- package/skills/tools/ocr-translate/latex-ocr-guide/SKILL.md +204 -0
- package/skills/tools/ocr-translate/multilingual-research-guide/SKILL.md +234 -0
- package/skills/tools/scraping/academic-web-scraping/SKILL.md +326 -0
- package/skills/tools/scraping/api-data-collection-guide/SKILL.md +301 -0
- package/skills/tools/scraping/web-scraping-ethics-guide/SKILL.md +250 -0
- package/skills/writing/citation/bibtex-management-guide/SKILL.md +246 -0
- package/skills/writing/citation/citation-style-guide/SKILL.md +248 -0
- package/skills/writing/citation/reference-manager-comparison/SKILL.md +208 -0
- package/skills/writing/citation/zotero-api/SKILL.md +188 -0
- package/skills/writing/composition/abstract-writing-guide/SKILL.md +188 -0
- package/skills/writing/composition/discussion-writing-guide/SKILL.md +194 -0
- package/skills/writing/composition/introduction-writing-guide/SKILL.md +194 -0
- package/skills/writing/composition/literature-review-writing/SKILL.md +196 -0
- package/skills/writing/composition/methods-section-guide/SKILL.md +185 -0
- package/skills/writing/composition/response-to-reviewers/SKILL.md +215 -0
- package/skills/writing/composition/scientific-writing-guide/SKILL.md +152 -0
- package/skills/writing/latex/bibliography-management-guide/SKILL.md +206 -0
- package/skills/writing/latex/latex-drawing-guide/SKILL.md +234 -0
- package/skills/writing/latex/latex-ecosystem-guide/SKILL.md +240 -0
- package/skills/writing/latex/math-typesetting-guide/SKILL.md +231 -0
- package/skills/writing/latex/overleaf-collaboration-guide/SKILL.md +211 -0
- package/skills/writing/latex/tikz-diagrams-guide/SKILL.md +211 -0
- package/skills/writing/polish/academic-translation-guide/SKILL.md +175 -0
- package/skills/writing/polish/academic-writing-refiner/SKILL.md +143 -0
- package/skills/writing/polish/ai-writing-humanizer/SKILL.md +178 -0
- package/skills/writing/polish/grammar-checker-guide/SKILL.md +184 -0
- package/skills/writing/polish/plagiarism-detection-guide/SKILL.md +167 -0
- package/skills/writing/templates/beamer-presentation-guide/SKILL.md +263 -0
- package/skills/writing/templates/conference-paper-template/SKILL.md +219 -0
- package/skills/writing/templates/thesis-template-guide/SKILL.md +200 -0
- package/skills/writing/templates/thesis-writing-guide/SKILL.md +220 -0
- package/src/tools/arxiv.ts +131 -0
- package/src/tools/crossref.ts +112 -0
- package/src/tools/openalex.ts +174 -0
- package/src/tools/pubmed.ts +166 -0
- package/src/tools/semantic-scholar.ts +108 -0
- package/src/tools/unpaywall.ts +58 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sandbox-execution-guide
|
|
3
|
+
description: "Secure sandboxed code execution environments for reproducible research computing"
|
|
4
|
+
metadata:
|
|
5
|
+
openclaw:
|
|
6
|
+
emoji: "shield"
|
|
7
|
+
category: "tools"
|
|
8
|
+
subcategory: "code-exec"
|
|
9
|
+
keywords: ["sandbox execution", "code runner", "literate programming", "containerization", "reproducible computing"]
|
|
10
|
+
source: "wentor"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Sandbox Execution Guide
|
|
14
|
+
|
|
15
|
+
A skill for setting up and using sandboxed code execution environments for research computing. Covers containerized execution, security considerations, resource management, and integration with research workflows.
|
|
16
|
+
|
|
17
|
+
## Why Sandboxed Execution?
|
|
18
|
+
|
|
19
|
+
Research code often requires:
|
|
20
|
+
- Isolation from the host system for security
|
|
21
|
+
- Reproducible environments across machines
|
|
22
|
+
- Resource limits to prevent runaway computations
|
|
23
|
+
- Multi-language support (Python, R, Julia, MATLAB)
|
|
24
|
+
|
|
25
|
+
## Docker-Based Sandboxes
|
|
26
|
+
|
|
27
|
+
### Creating a Research Container
|
|
28
|
+
|
|
29
|
+
```dockerfile
|
|
30
|
+
# Dockerfile for a reproducible research environment
|
|
31
|
+
FROM python:3.11-slim
|
|
32
|
+
|
|
33
|
+
# System dependencies
|
|
34
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
35
|
+
build-essential \
|
|
36
|
+
gfortran \
|
|
37
|
+
libopenblas-dev \
|
|
38
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
39
|
+
|
|
40
|
+
# Create non-root user for security
|
|
41
|
+
RUN useradd -m -s /bin/bash researcher
|
|
42
|
+
USER researcher
|
|
43
|
+
WORKDIR /home/researcher
|
|
44
|
+
|
|
45
|
+
# Pin all dependencies
|
|
46
|
+
COPY requirements.txt .
|
|
47
|
+
RUN pip install --user --no-cache-dir -r requirements.txt
|
|
48
|
+
|
|
49
|
+
# Copy project files
|
|
50
|
+
COPY --chown=researcher:researcher . /home/researcher/project
|
|
51
|
+
WORKDIR /home/researcher/project
|
|
52
|
+
|
|
53
|
+
# Resource limits set at runtime, not build time
|
|
54
|
+
CMD ["python", "main.py"]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Running with Resource Limits
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Run with CPU, memory, and time constraints
|
|
61
|
+
docker run \
|
|
62
|
+
--cpus="2.0" \
|
|
63
|
+
--memory="4g" \
|
|
64
|
+
--memory-swap="4g" \
|
|
65
|
+
--pids-limit=100 \
|
|
66
|
+
--network=none \
|
|
67
|
+
--read-only \
|
|
68
|
+
--tmpfs /tmp:size=512m \
|
|
69
|
+
--timeout 3600 \
|
|
70
|
+
research-sandbox:latest python analysis.py
|
|
71
|
+
|
|
72
|
+
# Mount data as read-only, output directory as writable
|
|
73
|
+
docker run \
|
|
74
|
+
-v /data/raw:/data:ro \
|
|
75
|
+
-v /data/results:/output:rw \
|
|
76
|
+
--cpus="4.0" \
|
|
77
|
+
--memory="16g" \
|
|
78
|
+
research-sandbox:latest python pipeline.py
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Python Sandbox with Resource Limits
|
|
82
|
+
|
|
83
|
+
### Process-Level Isolation
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import subprocess
|
|
87
|
+
import resource
|
|
88
|
+
import signal
|
|
89
|
+
import tempfile
|
|
90
|
+
import os
|
|
91
|
+
|
|
92
|
+
def run_sandboxed(code: str, timeout: int = 60,
|
|
93
|
+
max_memory_mb: int = 512) -> dict:
|
|
94
|
+
"""
|
|
95
|
+
Execute Python code in a sandboxed subprocess with resource limits.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
code: Python code string to execute
|
|
99
|
+
timeout: Maximum execution time in seconds
|
|
100
|
+
max_memory_mb: Maximum memory in megabytes
|
|
101
|
+
"""
|
|
102
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f:
|
|
103
|
+
f.write(code)
|
|
104
|
+
script_path = f.name
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
result = subprocess.run(
|
|
108
|
+
['python', '-u', script_path],
|
|
109
|
+
capture_output=True,
|
|
110
|
+
text=True,
|
|
111
|
+
timeout=timeout,
|
|
112
|
+
env={
|
|
113
|
+
'PATH': '/usr/bin:/usr/local/bin',
|
|
114
|
+
'HOME': '/tmp',
|
|
115
|
+
'PYTHONDONTWRITEBYTECODE': '1'
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
return {
|
|
119
|
+
'stdout': result.stdout,
|
|
120
|
+
'stderr': result.stderr,
|
|
121
|
+
'returncode': result.returncode,
|
|
122
|
+
'timed_out': False
|
|
123
|
+
}
|
|
124
|
+
except subprocess.TimeoutExpired:
|
|
125
|
+
return {
|
|
126
|
+
'stdout': '',
|
|
127
|
+
'stderr': f'Execution timed out after {timeout}s',
|
|
128
|
+
'returncode': -1,
|
|
129
|
+
'timed_out': True
|
|
130
|
+
}
|
|
131
|
+
finally:
|
|
132
|
+
os.unlink(script_path)
|
|
133
|
+
|
|
134
|
+
# Example usage
|
|
135
|
+
result = run_sandboxed("""
|
|
136
|
+
import numpy as np
|
|
137
|
+
data = np.random.randn(1000)
|
|
138
|
+
print(f"Mean: {data.mean():.4f}")
|
|
139
|
+
print(f"Std: {data.std():.4f}")
|
|
140
|
+
""", timeout=30, max_memory_mb=256)
|
|
141
|
+
print(result['stdout'])
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Nix-Based Reproducible Environments
|
|
145
|
+
|
|
146
|
+
For maximum reproducibility, use Nix to pin every dependency including system libraries:
|
|
147
|
+
|
|
148
|
+
```nix
|
|
149
|
+
# shell.nix for a research project
|
|
150
|
+
{ pkgs ? import (fetchTarball {
|
|
151
|
+
url = "https://github.com/NixOS/nixpkgs/archive/nixos-23.11.tar.gz";
|
|
152
|
+
}) {} }:
|
|
153
|
+
|
|
154
|
+
pkgs.mkShell {
|
|
155
|
+
buildInputs = with pkgs; [
|
|
156
|
+
python311
|
|
157
|
+
python311Packages.numpy
|
|
158
|
+
python311Packages.scipy
|
|
159
|
+
python311Packages.pandas
|
|
160
|
+
python311Packages.matplotlib
|
|
161
|
+
python311Packages.scikit-learn
|
|
162
|
+
R
|
|
163
|
+
rPackages.ggplot2
|
|
164
|
+
rPackages.dplyr
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
shellHook = ''
|
|
168
|
+
echo "Research sandbox activated"
|
|
169
|
+
echo "Python: $(python --version)"
|
|
170
|
+
echo "R: $(R --version | head -1)"
|
|
171
|
+
'';
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Enter the reproducible environment
|
|
177
|
+
nix-shell shell.nix
|
|
178
|
+
|
|
179
|
+
# Or use flakes for even better reproducibility
|
|
180
|
+
nix develop
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Security Best Practices
|
|
184
|
+
|
|
185
|
+
When running untrusted or third-party code:
|
|
186
|
+
|
|
187
|
+
1. **Network isolation**: Use `--network=none` in Docker to prevent data exfiltration
|
|
188
|
+
2. **Filesystem restrictions**: Mount data as read-only, limit writable paths
|
|
189
|
+
3. **Resource caps**: Always set CPU, memory, and time limits
|
|
190
|
+
4. **User isolation**: Run as non-root user inside the container
|
|
191
|
+
5. **Syscall filtering**: Use seccomp profiles to restrict system calls
|
|
192
|
+
6. **Output sanitization**: Validate and sanitize all output before processing
|
|
193
|
+
|
|
194
|
+
## Integration with CI/CD
|
|
195
|
+
|
|
196
|
+
Automate research pipeline execution with GitHub Actions:
|
|
197
|
+
|
|
198
|
+
```yaml
|
|
199
|
+
name: Research Pipeline
|
|
200
|
+
on:
|
|
201
|
+
push:
|
|
202
|
+
paths: ['src/**', 'data/**']
|
|
203
|
+
|
|
204
|
+
jobs:
|
|
205
|
+
run-analysis:
|
|
206
|
+
runs-on: ubuntu-latest
|
|
207
|
+
container:
|
|
208
|
+
image: research-sandbox:latest
|
|
209
|
+
options: --cpus 4 --memory 8g
|
|
210
|
+
steps:
|
|
211
|
+
- uses: actions/checkout@v4
|
|
212
|
+
- run: python src/01_preprocess.py
|
|
213
|
+
- run: python src/02_analyze.py
|
|
214
|
+
- run: python src/03_visualize.py
|
|
215
|
+
- uses: actions/upload-artifact@v4
|
|
216
|
+
with:
|
|
217
|
+
name: results
|
|
218
|
+
path: output/
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
This ensures every commit triggers a fresh, sandboxed execution of the full pipeline, catching environment-dependent bugs and ensuring reproducibility.
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mermaid-diagram-guide
|
|
3
|
+
description: "Create flowcharts, sequence diagrams, and architecture diagrams with Mermaid"
|
|
4
|
+
metadata:
|
|
5
|
+
openclaw:
|
|
6
|
+
emoji: "📋"
|
|
7
|
+
category: "tools"
|
|
8
|
+
subcategory: "diagram"
|
|
9
|
+
keywords: ["flow chart", "architecture diagram", "Mermaid", "UML diagram", "graphical abstract"]
|
|
10
|
+
source: "N/A"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Mermaid Diagram Guide
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
Mermaid is a text-based diagramming tool that renders diagrams from Markdown-like syntax. For researchers, Mermaid offers a unique combination of version-controllable source code, instant rendering in documentation platforms (GitHub, GitLab, Notion, Obsidian), and enough expressiveness to create flowcharts, sequence diagrams, class diagrams, Gantt charts, and more.
|
|
18
|
+
|
|
19
|
+
Unlike graphical tools like draw.io or Lucidchart, Mermaid diagrams live as plain text in your documentation, making them easy to maintain alongside code and papers. They are especially valuable for research documentation, README files, software architecture diagrams in methods sections, and graphical abstracts.
|
|
20
|
+
|
|
21
|
+
This guide covers the most useful Mermaid diagram types for academic work, with complete syntax references and real-world examples from research contexts. Each diagram type includes a template you can copy and modify for your specific needs.
|
|
22
|
+
|
|
23
|
+
## Flowcharts
|
|
24
|
+
|
|
25
|
+
Flowcharts are the most common diagram type for describing algorithms, experimental procedures, and data processing pipelines.
|
|
26
|
+
|
|
27
|
+
### Basic Syntax
|
|
28
|
+
|
|
29
|
+
```mermaid
|
|
30
|
+
flowchart TD
|
|
31
|
+
A[Start] --> B{Decision}
|
|
32
|
+
B -->|Yes| C[Process A]
|
|
33
|
+
B -->|No| D[Process B]
|
|
34
|
+
C --> E[End]
|
|
35
|
+
D --> E
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Node Shapes
|
|
39
|
+
|
|
40
|
+
| Shape | Syntax | Use Case |
|
|
41
|
+
|-------|--------|----------|
|
|
42
|
+
| Rectangle | `A[text]` | Process step |
|
|
43
|
+
| Rounded | `A(text)` | Start/end |
|
|
44
|
+
| Diamond | `A{text}` | Decision |
|
|
45
|
+
| Hexagon | `A{{text}}` | Preparation |
|
|
46
|
+
| Parallelogram | `A[/text/]` | Input/output |
|
|
47
|
+
| Circle | `A((text))` | Connector |
|
|
48
|
+
| Stadium | `A([text])` | Terminal |
|
|
49
|
+
|
|
50
|
+
### Research Pipeline Example
|
|
51
|
+
|
|
52
|
+
```mermaid
|
|
53
|
+
flowchart TD
|
|
54
|
+
subgraph Data Collection
|
|
55
|
+
A[Raw Data] --> B[Quality Check]
|
|
56
|
+
B --> C{Pass QC?}
|
|
57
|
+
C -->|No| D[Exclude]
|
|
58
|
+
C -->|Yes| E[Clean Data]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
subgraph Analysis
|
|
62
|
+
E --> F[Feature Extraction]
|
|
63
|
+
F --> G[Model Training]
|
|
64
|
+
G --> H[Cross-Validation]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
subgraph Evaluation
|
|
68
|
+
H --> I{Significant?}
|
|
69
|
+
I -->|Yes| J[Report Results]
|
|
70
|
+
I -->|No| K[Revise Hypothesis]
|
|
71
|
+
K --> F
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
style A fill:#3B82F6,color:#fff
|
|
75
|
+
style J fill:#16A34A,color:#fff
|
|
76
|
+
style D fill:#EF4444,color:#fff
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Direction Options
|
|
80
|
+
|
|
81
|
+
| Direction | Code | Description |
|
|
82
|
+
|-----------|------|-------------|
|
|
83
|
+
| Top to bottom | `TD` or `TB` | Default, vertical |
|
|
84
|
+
| Bottom to top | `BT` | Vertical, upward |
|
|
85
|
+
| Left to right | `LR` | Horizontal |
|
|
86
|
+
| Right to left | `RL` | Horizontal, reversed |
|
|
87
|
+
|
|
88
|
+
## Sequence Diagrams
|
|
89
|
+
|
|
90
|
+
Sequence diagrams show interactions between components over time. They are ideal for describing API calls, protocol steps, and system interactions.
|
|
91
|
+
|
|
92
|
+
```mermaid
|
|
93
|
+
sequenceDiagram
|
|
94
|
+
participant U as User
|
|
95
|
+
participant F as Frontend
|
|
96
|
+
participant A as API Server
|
|
97
|
+
participant DB as Database
|
|
98
|
+
|
|
99
|
+
U->>F: Submit experiment
|
|
100
|
+
F->>A: POST /experiments
|
|
101
|
+
A->>DB: INSERT experiment
|
|
102
|
+
DB-->>A: experiment_id
|
|
103
|
+
A->>A: Queue processing job
|
|
104
|
+
|
|
105
|
+
Note over A: Async processing begins
|
|
106
|
+
|
|
107
|
+
A-->>F: 202 Accepted {id}
|
|
108
|
+
F-->>U: "Experiment submitted"
|
|
109
|
+
|
|
110
|
+
loop Every 5 seconds
|
|
111
|
+
F->>A: GET /experiments/{id}/status
|
|
112
|
+
A-->>F: {status: "running"}
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
A-->>F: {status: "complete", results: {...}}
|
|
116
|
+
F-->>U: Display results
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Arrow Types
|
|
120
|
+
|
|
121
|
+
| Arrow | Syntax | Meaning |
|
|
122
|
+
|-------|--------|---------|
|
|
123
|
+
| Solid with arrowhead | `->>` | Synchronous call |
|
|
124
|
+
| Dotted with arrowhead | `-->>` | Response/return |
|
|
125
|
+
| Solid | `->` | Message |
|
|
126
|
+
| Dotted | `-->` | Optional message |
|
|
127
|
+
| Cross | `-x` | Failed message |
|
|
128
|
+
|
|
129
|
+
## Class Diagrams
|
|
130
|
+
|
|
131
|
+
Class diagrams document code architecture and data models:
|
|
132
|
+
|
|
133
|
+
```mermaid
|
|
134
|
+
classDiagram
|
|
135
|
+
class Experiment {
|
|
136
|
+
+String id
|
|
137
|
+
+String name
|
|
138
|
+
+DateTime created_at
|
|
139
|
+
+Status status
|
|
140
|
+
+run()
|
|
141
|
+
+get_results() Results
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
class Dataset {
|
|
145
|
+
+String path
|
|
146
|
+
+int n_samples
|
|
147
|
+
+int n_features
|
|
148
|
+
+load() DataFrame
|
|
149
|
+
+split(ratio) TrainTest
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
class Model {
|
|
153
|
+
+String architecture
|
|
154
|
+
+Dict hyperparams
|
|
155
|
+
+train(Dataset)
|
|
156
|
+
+predict(Dataset) Array
|
|
157
|
+
+evaluate(Dataset) Metrics
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
Experiment "1" --> "1..*" Dataset : uses
|
|
161
|
+
Experiment "1" --> "1..*" Model : trains
|
|
162
|
+
Model ..> Dataset : depends on
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Gantt Charts
|
|
166
|
+
|
|
167
|
+
Gantt charts are useful for project timelines and research plans:
|
|
168
|
+
|
|
169
|
+
```mermaid
|
|
170
|
+
gantt
|
|
171
|
+
title Research Project Timeline
|
|
172
|
+
dateFormat YYYY-MM-DD
|
|
173
|
+
axisFormat %b %Y
|
|
174
|
+
|
|
175
|
+
section Literature Review
|
|
176
|
+
Survey existing work :done, lit1, 2026-01-01, 30d
|
|
177
|
+
Identify research gap :done, lit2, after lit1, 14d
|
|
178
|
+
|
|
179
|
+
section Methodology
|
|
180
|
+
Design experiments :active, meth1, after lit2, 21d
|
|
181
|
+
Implement baseline :meth2, after meth1, 14d
|
|
182
|
+
|
|
183
|
+
section Experiments
|
|
184
|
+
Run baseline experiments :exp1, after meth2, 21d
|
|
185
|
+
Run proposed method :exp2, after exp1, 21d
|
|
186
|
+
Ablation studies :exp3, after exp2, 14d
|
|
187
|
+
|
|
188
|
+
section Writing
|
|
189
|
+
Draft paper :write1, after exp2, 30d
|
|
190
|
+
Internal review :write2, after write1, 14d
|
|
191
|
+
Submit to conference :milestone, after write2, 0d
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## State Diagrams
|
|
195
|
+
|
|
196
|
+
State diagrams model entity lifecycles:
|
|
197
|
+
|
|
198
|
+
```mermaid
|
|
199
|
+
stateDiagram-v2
|
|
200
|
+
[*] --> Draft
|
|
201
|
+
Draft --> UnderReview : Submit
|
|
202
|
+
UnderReview --> MinorRevision : Reviewer feedback
|
|
203
|
+
UnderReview --> MajorRevision : Reviewer feedback
|
|
204
|
+
UnderReview --> Rejected : Reviewer feedback
|
|
205
|
+
MinorRevision --> UnderReview : Resubmit
|
|
206
|
+
MajorRevision --> UnderReview : Resubmit
|
|
207
|
+
UnderReview --> Accepted : Final decision
|
|
208
|
+
Accepted --> Published : Camera-ready
|
|
209
|
+
Rejected --> Draft : Revise for new venue
|
|
210
|
+
Published --> [*]
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Rendering and Integration
|
|
214
|
+
|
|
215
|
+
### GitHub / GitLab
|
|
216
|
+
|
|
217
|
+
Both platforms render Mermaid natively in Markdown files:
|
|
218
|
+
|
|
219
|
+
````markdown
|
|
220
|
+
```mermaid
|
|
221
|
+
flowchart LR
|
|
222
|
+
A --> B --> C
|
|
223
|
+
```
|
|
224
|
+
````
|
|
225
|
+
|
|
226
|
+
### Command-Line Rendering
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Install Mermaid CLI
|
|
230
|
+
npm install -g @mermaid-js/mermaid-cli
|
|
231
|
+
|
|
232
|
+
# Render to PNG
|
|
233
|
+
mmdc -i diagram.mmd -o diagram.png -w 1200
|
|
234
|
+
|
|
235
|
+
# Render to SVG (preferred for papers)
|
|
236
|
+
mmdc -i diagram.mmd -o diagram.svg
|
|
237
|
+
|
|
238
|
+
# Render to PDF
|
|
239
|
+
mmdc -i diagram.mmd -o diagram.pdf
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Embedding in LaTeX
|
|
243
|
+
|
|
244
|
+
```latex
|
|
245
|
+
% Include the SVG generated by mmdc
|
|
246
|
+
\usepackage{svg}
|
|
247
|
+
\begin{figure}[h]
|
|
248
|
+
\centering
|
|
249
|
+
\includesvg[width=0.8\textwidth]{diagram}
|
|
250
|
+
\caption{System architecture overview.}
|
|
251
|
+
\end{figure}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Best Practices
|
|
255
|
+
|
|
256
|
+
- **Keep diagrams focused.** One concept per diagram. If it exceeds 15-20 nodes, split it.
|
|
257
|
+
- **Use subgraphs for grouping.** They clarify which components belong together.
|
|
258
|
+
- **Label all edges.** Unlabeled arrows are ambiguous.
|
|
259
|
+
- **Use consistent styling.** Define colors for success (green), failure (red), and process (blue) states.
|
|
260
|
+
- **Export as SVG for papers.** SVG scales perfectly and produces crisp output at any size.
|
|
261
|
+
- **Version-control your diagrams.** Since Mermaid is text, it diffs cleanly in Git.
|
|
262
|
+
- **Test in the live editor.** Use [mermaid.live](https://mermaid.live/) to iterate quickly before committing.
|
|
263
|
+
|
|
264
|
+
## References
|
|
265
|
+
|
|
266
|
+
- [Mermaid Documentation](https://mermaid.js.org/) -- Official reference
|
|
267
|
+
- [Mermaid Live Editor](https://mermaid.live/) -- Interactive diagram editor
|
|
268
|
+
- [Mermaid CLI](https://github.com/mermaid-js/mermaid-cli) -- Command-line rendering tool
|
|
269
|
+
- [GitHub Mermaid Support](https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/) -- Native rendering in GitHub
|