nsfc-schematic
Original:🇨🇳 Chinese
Translated
22 scripts
Use this when users explicitly request to "generate NSFC schematic diagram/mechanism diagram" or need to convert the research mechanism, algorithm architecture, and module relationships in the proposal into "editable + embeddable" diagrams. By default, editable source files (`.drawio`) and rendered files (`.pdf`/`.svg`/`.png`) are output; when users actively mention the Nano Banana/Gemini image model, you can switch to PNG-only mode. ⚠️ Not applicable scenarios: Users only want to polish the main text (should rewrite text directly), only want to modify the format/size of existing images (should use image processing skills), and have no clear intention of requiring "schematic/mechanism diagram".
8installs
Added on
NPX Install
npx skill4agent add huangwb8/chineseresearchlatex nsfc-schematicTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →NSFC Schematic Generator
Important Disclaimer (Unofficial)
- This skill is only used for scientific research writing and visualization expression optimization, and does not represent any official review standards or funding conclusions.
Security and Privacy (Hard Rules)
- By default, proposal content is treated as sensitive information: only process files or directories explicitly provided by users.
- Only retain necessary scientific research terms in the output diagram, avoid writing irrelevant personal information.
- Do not crawl materials online by default; if users require online supplementation, explain the risks first.
Input
Users need to provide at least one of the following:
- : Structured diagram specification file (recommended, most controllable)
spec_file - : Single proposal file (such as
proposal_fileormain.tex)extraTex/*.tex - : Proposal directory (automatically search for
proposal_pathfiles).tex
Optional:
- : Optimization rounds (default refers to
rounds)config.yaml:evaluation.max_rounds - : Rendering backend (default
renderer; only allowed to usedrawiowhen users actively mention the Nano Banana/Gemini image model, this mode only outputs PNG)nano_banana - : Output directory (optional; default uses
output_dir, relative to the current working directory)config.yaml:output.dirname - : Configuration file path (optional; default uses the built-in
configof the skill; used to individually override parameters such asnsfc-schematic/config.yamlfor a specific project)output.hide_intermediate - : Natural language mechanism description (only used for "planning mode"; planning draft and spec draft are generated by
context)plan_schematic.py - : Diagram type template id/family (advanced option; default "pure AI planning" does not require or recommend setting)
template_ref
Output
Generated under (each run will create an isolated directory to avoid mixing historical residues):
output_dirrun_*/round_*- : Editable source file
schematic.drawio - : Recommended for embedding in LaTeX/Word (vector first; downgraded to PNG→PDF raster when draw.io CLI is unavailable)
schematic.pdf - : Vector diagram (more suitable for web pages/slides; draw.io SVG may contain foreignObject, and some toolchains will lose text)
schematic.svg - : Preview image
schematic.png - Nano Banana / Gemini PNG-only mode: Deliver 4K + significantly smaller
schematic.png(downsample and compress the 4K image by default, suitable for embedding in proposal PDF; noschematic_compacted.pnggenerated).drawio/.svg/.pdf - : Intermediate product directory (hidden by default; directory name is configurable)
.nsfc-schematic/- : Latest optimization record (overwritten and updated each run)
optimization_report.md - : Latest spec used (easy to reproduce/trace)
spec_latest.yaml - /
config_used_best.yaml: Latest best round reproduction evidenceevaluation_best.json - : Current run directory (contains
runs/run_YYYYMMDDHHMMSS(__tag)/, each round of evaluation and rendering products;round_*will be added when using__tag)--run-tag - : Closed-loop workspace for
ai/(stop_strategy=ai_critic,ACTIVE_RUN.txt,{run}/ai_pack_round_XX/,ai_critic_request.md)ai_critic_response.yaml - : Automatically migrated/stored historical residues (such as old version output
legacy/,run_*,spec*.yaml,config_*.yaml, etc.)evaluation_*.json
By default, the root directory of only retains delivery files (drawio/svg/png/pdf) and the hidden directory to avoid intermediate files polluting the user's working directory.
output_dir.nsfc-schematic/Compatibility mode:
- If you need to restore the old behavior (intermediate files and are written directly to the root directory of
run_*), setoutput_dir.config.yaml:output.hide_intermediate=false
Each generates the following "traceable evidence" by default (can be turned off via ):
round_*/config.yaml:evaluation.*- : Main evaluator result (includes
evaluation.json)score_base/score_penalty/score_total - : Layout diagnosis (node/group geometric information)
layout_debug.json - : Connection diagnosis (edge id, kind, route, waypoints)
edge_debug.json - : Pure metric evidence for main evaluation
measurements.json - : Structural/visual/readability dimension evidence (summarized by critique)
dimension_measurements.json - : Multi-dimensional critical self-check evidence (
critique_structure.json / critique_visual.json / critique_readability.json; only generated under heuristic evaluation or AI fallback path to avoid duplicate point deduction with AI standards)evaluation.multi_round_self_check - : Limited candidate comparison per round (
_candidates/)evaluation.exploration.candidates_per_round
When (optional enhancement), the script will output offline protocol files (the script does not call external models locally):
config.yaml:evaluation.evaluation_mode=ai- +
round_*/_candidates/cand_*/ai_eval_request.md: AI evaluation request/response (main evaluation)ai_eval_response.json - +
run_*/ai_tex_request.md: When the input comes from TEX and no spec_file is provided, it is used for the offline request/response of "AI directly reads TEX → generates spec draft" (automatically downgrades to regular extraction if there is no response)ai_tex_response.json
Planning mode delivery:
- : Planning draft (written by the host AI; the script is responsible for generating the request protocol and performing legitimacy verification when re-running)
output_dir/schematic-plan.md - (Optional) : If you need to copy an extra copy to the current working directory for easy review, use
schematic-plan.mdplan_schematic.py --also-write-workspace-plan
Spec v2 (backward compatible with old versions)
- is now optional: if missing, the script generates a stable id according to
node.id(reproducible).group + label + index - supports explicit edge protocol:
schematic.edges
yaml
edges:
- id: e_input_core
from: input_layer.data_input # 支持 group.node 路径引用
to: process_layer.core_module
kind: main # main|aux|risk|validate
route: orthogonal # orthogonal|straight|auto
label: 输入数据- Rendering priority:
- If are provided: output strictly according to explicit edges;
edges - If are not provided: fall back to
edges(layout.auto_edges).minimal|off
- If
Correction Principles
- For crowding issues, prioritize modifying the spec (shorten text/merge nodes/reduce nodes), do not force the threshold by reducing the font size.
- Only reduce the font size when there is a risk of overflow; if the font size is small and there is no overflow, increase the font size.
- For color matching interference, prioritize modifying the kind allocation, do not use black and white schemes to cover up structural problems.
Workflow
Read Configuration (Mandatory)
Read before starting, and use it as the single source of truth for execution:
config.yaml- : Canvas size, font, rendering behavior
renderer - : Prompt when draw.io CLI is missing / (optional) automatic installation strategy
renderer.drawio - : Automatic layout parameters
layout - : Automatic connection strategy when no explicit edges are provided (
layout.auto_edges)minimal|off - : Diagram type template (advanced option; disabled by default; the model gallery is only for learning, see
layout.template_ref)references/models/templates.yaml - : In-diagram title switch and top reservation (in-diagram title is disabled by default, external figure caption is recommended)
layout.title - : Node text "automatic expansion" strategy (avoid text overflow/occlusion after export)
layout.text_fit - : Whether to automatically expand the canvas to avoid out-of-bounds after nodes/groups are automatically expanded
layout.auto_expand_canvas - : Canvas fitting strategy (optional shrink according to content boundary; and center the content bbox to reduce unilateral white space)
layout.canvas_fit - : Routing avoidance parameters (more conservative obstacle padding, avoid group title bar)
layout.routing - : Connection label font size (edge label does not automatically follow
layout.font.edge_label_size, need to be configured separately)node_label_size - : Color scheme
color_scheme - : Scoring threshold, stop strategy (stop_strategy), weight and multi-round exploration parameters
evaluation - : Evaluation mode (default
evaluation.evaluation_mode;heuristicis optional enhancement: output offline AI protocol files and consume host AI responses; automatically downgrade if there is no response)ai - : Connection label font size access threshold (including reduced print equivalent font size check)
evaluation.thresholds.min_edge_font_px/warn_edge_font_px - : Spec security variants (disabled by default; only wrap/truncate/candidates for labels, used to alleviate crowding/overflow caused by long text)
evaluation.spec_variants - /
output.hide_intermediate: Intermediate file hiding strategy and directory nameoutput.intermediate_dir - : Keep up to the latest N
output.max_history_runs(only effective when hide_intermediate=true)run_* - : Instance-level override (whitelist:
output_dir/.nsfc-schematic/config_local.yaml,renderer.canvas/stroke/drawio.cli_path/internal_routing,layout.direction/font/auto_edges/canvas_fit.center_content/auto{margin,gap,max_cols},color_scheme.name)evaluation.stop_strategy/max_rounds/spec_variants/exploration{seed,candidates_per_round,enabled} - : Diagram type template library path (default
planning.models_file)references/models/templates.yaml - : Planning mode (
planning.planning_mode; defaultai|template: pure AI planning protocol)ai
Planning Mode (Recommended for First Use)
When users generate schematics for the proposal for the first time, it is recommended to "plan → review → regenerate" first:
- Investigate the proposal and generate a "planning request protocol" (the script will comprehensively extract "project basis + research content/technical route", and generate a model gallery for learning; no need to select a template):
bash
python3 nsfc-schematic/scripts/plan_schematic.py \
--proposal /path/to/proposal/ \
--output ./schematic_plan/(Compatible with old processes) If you want the script to directly generate a draft according to deterministic rules (template planning), use:
bash
python3 nsfc-schematic/scripts/plan_schematic.py \
--mode template \
--proposal /path/to/proposal/ \
--output ./schematic_plan/Or use natural language description:
bash
python3 nsfc-schematic/scripts/plan_schematic.py \
--context "用一句话/一段话描述机制与模块关系..." \
--output ./schematic_plan/- Host AI pure planning: According to the requirements of , write:
./schematic_plan/.nsfc-schematic/planning/plan_request.md
./schematic_plan/schematic-plan.md./schematic_plan/spec_draft.yaml
(Optional visual learning) The planning script will (try its best) generate a "model gallery" in the directory (used to learn excellent structures/styles):
--output- : Skeleton/pattern diagram (recommended to view first)
./schematic_plan/.nsfc-schematic/planning/models_simple_contact_sheet.png - : Complete reference diagram (used for style and detail completion)
./schematic_plan/.nsfc-schematic/planning/models_contact_sheet.png
- Run the planning script again for legitimacy verification (the script will verify the spec structure and give P0/WARN prompts):
bash
python3 nsfc-schematic/scripts/plan_schematic.py \
--proposal /path/to/proposal/ \
--output ./schematic_plan/- Review and
schematic_plan/schematic-plan.md: Confirm whether the module division, node list, connection relationship and layout suggestions are reasonable.schematic_plan/spec_draft.yaml- If you need to manually draft a planning draft, you can refer to:
nsfc-schematic/references/plan_template.md
- If you need to manually draft a planning draft, you can refer to:
- Use to enter multi-round generation and optimization:
generate_schematic.py
bash
python3 nsfc-schematic/scripts/generate_schematic.py \
--spec-file ./schematic_plan/spec_draft.yaml \
--output-dir ./schematic_output/ \
--rounds 5Generation Process (Default Entry)
bash
python3 nsfc-schematic/scripts/generate_schematic.py \
--spec-file nsfc-schematic/references/spec_examples/ccs_framework.yaml \
--output-dir ./schematic_output \
--rounds 5Process breakdown:
- Parse the spec () and automatically complete the layout.
spec_parser.py - Generate draw.io XML ().
schematic_writer.py - Pre-check (P0): Perform XML well-formed verification on ; if it fails, stop immediately and give a readable error.
.drawio - Render SVG/PNG/PDF ().
render_schematic.py - Evaluate diagram quality (), and enhance the identification and classification of "near-blank rendering/content loss".
evaluate_schematic.py - Multi-dimensional self-check (): Structural/visual/readability independent evidence is written to disk, and
evaluate_dimension.pyis obtained by linear deduction of defects.score_total - Record the results of each round and export the best round.
Generation Process (Nano Banana / Gemini PNG-only, only when users actively request)
Hard rule: Only when users explicitly propose to use the Nano Banana/Gemini image model (for example, users say "use Nano Banana", "use Gemini to generate images", "do not use draw.io"), this mode is allowed to be enabled; otherwise, the default draw.io process must be maintained.
Prerequisites: Configure and connectable in the project root directory (or system environment variables):
.env- (example:
GEMINI_BASE_URL)https://generativelanguage.googleapis.com/v1beta - (Gemini API Key)
GEMINI_API - (example:
GEMINI_MODEL)gemini-3.1-flash-image-preview
It is recommended to do a connectivity check first (no images will be output):
bash
python3 nsfc-schematic/scripts/nano_banana_check.pyIf you are not executing in the project root directory, you can explicitly specify :
.envbash
python3 nsfc-schematic/scripts/nano_banana_check.py --dotenv /path/to/.envGenerate PNG (default ; only output ):
--rounds 5schematic.pngbash
python3 nsfc-schematic/scripts/generate_schematic.py \
--renderer nano_banana \
--dotenv /path/to/.env \
--spec-file ./schematic_plan/spec_draft.yaml \
--output-dir ./schematic_output/ \
--rounds 5Description:
- In Nano Banana mode, the script will automatically disable SVG/PDF export, and only generate 1 candidate per round (to avoid cost multiplication; for multi-scheme comparison, please use multi-thread parallelism).
parallel-vibe - The prompt of this mode is deterministically constructed from the spec (group/node/edges), and includes hard constraints of "print-level text layout" (prohibiting text distortion/rotation/art fonts, etc.); during optimization, priority is given to modifying the label length, group boundary and edge relationship of the spec to ensure "readable after reduced printing".
Evaluation-Optimization Loop (Default: AI Closed Loop)
- Default configuration:
evaluation.stop_strategy=ai_critic - Script behavior:
- Each run only advances 1 round, pauses after generating the evidence package, waiting for the host AI response
- Automatically score and write evidence to disk (+
evaluation.json+*_debug.json)measurements*.json - After the host AI writes back , resume to advance to the next round; write
ai_critic_response.yamlto export the final delivery fileaction: stop
- If you need unattended automatic convergence, you can override it to in
stop_strategy: plateauconfig_local.yaml
Multi-scheme Parallel Optimization (parallel-vibe, optional, recommended for "opening many runs and comparing repeatedly")
Applicable: When you need to try different optimization strategies (canvas/font size/spacing/routing/exploration seed, etc.) at the same time, avoid repeatedly modifying in the same leading to run confusion.
config_local.yamloutput_dirCore strategy: Use to create multiple isolated workspaces, each thread maintains a separate (only whitelist fields), and uses to mark the source of this run.
parallel-vibeoutput_dir/.nsfc-schematic/config_local.yaml--run-tagDefault recommended to open 5 threads (aligned with the "default rounds" of ; it is also more convenient to filter out obviously inferior solutions in 1 round).
evaluation.max_rounds=5Recommended threads (example, split according to common pain points):
- thread_1 (structure and white space): Increase , increase the canvas if necessary
layout.auto.group_gap_y/node_gap_y - thread_2 (readability first): Increase , increase the canvas if necessary
layout.font.node_label_size/edge_label_size - thread_3 (connection and interpretability): Switch or disable
renderer.internal_routing=straightlayout.auto_edges - thread_4 (jump out of local optimum): Keep the structure unchanged, only modify (let the exploration jitter take another trajectory)
evaluation.exploration.seed
It is recommended to run a small number of rounds for quick screening for each thread (such as ), and then return to the main workspace for fine-tuning with higher rounds after selecting the best (such as ).
--rounds 3--rounds 7AI Autonomous Closed Loop (ai_critic, Offline Protocol)
Default mode. Each run only advances 1 round, the host AI evaluates the evidence package and decides the next step. If you need to fall back to unattended automatic convergence, you can override in .
stop_strategy: plateauconfig_local.yaml- Run the generation script (only advance 1 round each time):
bash
python3 nsfc-schematic/scripts/generate_schematic.py \
--spec-file ./schematic_plan/spec_draft.yaml \
--output-dir ./schematic_output/- Find the request and evidence package (the script will prompt the path; default in the hidden directory):
- : Current closed-loop run (for resume)
output_dir/.nsfc-schematic/ai/ACTIVE_RUN.txt - : Host AI instructions
output_dir/.nsfc-schematic/ai/<run>/ai_critic_request.md - : Evidence package (includes
output_dir/.nsfc-schematic/ai/<run>/ai_pack_round_XX/+schematic.png, etc.; ifevaluation.json, it will also includerenderer=nano_banana)nano_banana_prompt.md
- Host AI writes back the response:
Write according to the protocol of :
ai_critic_request.mdoutput_dir/.nsfc-schematic/ai/<run>/ai_critic_response.yaml
Additional agreement for Nano Banana (Gemini PNG-only) + ai_critic:
- The host AI should give priority to visual judgment by directly reading the image ();
schematic.pngare only for reference.evaluation.json/*_debug.json - The host AI needs to judge whether the current "overall style" (composition/line/color matching/texture) is good enough:
- If good enough: write ; the next round will pass the previous round's
style_continuity: trueas a reference image to Gemini to ensure style continuity.schematic.png - If major changes are still needed: write ; no reference image is passed in the next round (to avoid solidifying bad styles).
style_continuity: false
- If good enough: write
- If you think the color matching still needs optimization, you can write ; the script will automatically splice it into the next round's prompt.
nano_banana_color_advice
Minimum example (general):
yaml
version: 1
based_on_round: 1
action: config_only # spec_only|config_only|both|stop
reason: "一句话说明为什么这样改"
config_local:
layout:
font:
node_label_size: 28Minimum example (only for Nano Banana, optional fields):
yaml
version: 1
based_on_round: 1
action: nano_banana_prompt_only # spec_only|config_only|both|nano_banana_prompt_only|stop
reason: "风格已满意,锁定风格并微调配色"
style_continuity: true
nano_banana_color_advice: |
- 主色不超过 2-3 个;风险/对照用点缀色
- 保证文本对比度(深色字 + 浅色填充)- Resume:
Run again to automatically consume the response and advance to the next round; after writing , the script will clear and export the final delivery file.
generate_schematic.pyaction: stopACTIVE_RUN.txtScript Responsibilities
- : Parse/verify spec, complete automatic layout, verify edges.
scripts/spec_parser.py - : Convert standardized spec to draw.io XML.
scripts/schematic_writer.py - : Prioritize draw.io CLI rendering; use internal fallback rendering when missing.
scripts/render_schematic.py - : Generate/consume AI evaluation offline protocols (ai_eval_request.md / ai_eval_response.json), do not call external models in the script.
scripts/ai_evaluate.py - : Generate/consume AI TEX extraction offline protocols (ai_tex_request.md / ai_tex_response.json), do not call external models in the script.
scripts/ai_extract_tex.py - : "Pure metric collection layer" for main evaluation (geometry/routing/pixel proxy), retained for heuristic evaluation and downgrade fallback.
scripts/measure_schematic.py - : "Pure metric collection layer" for multi-dimensional self-check (structure/visual/readability), retained for heuristic self-check and downgrade fallback.
scripts/measure_dimension.py - : Heuristic evaluation (fallback); when
scripts/evaluate_schematic.pyis enabled, output offline AI protocol and consume the host AI's review response (automatically fall back to heuristic if missing).evaluation_mode=ai - : Heuristic multi-dimensional self-check (used for penalty deduction; skipped by default when AI main evaluation takes effect to avoid duplicate caliber).
scripts/evaluate_dimension.py - : Deterministic orthogonal routing (waypoints), used for rendering fallback, drawio writing and evaluation caliber alignment.
scripts/routing.py - : Extract terms from TEX for initial spec filling.
scripts/extract_from_tex.py - : One-click orchestration of multi-round iterations.
scripts/generate_schematic.py - :
scripts/env_utils.pyparsing and upward search (used to read GEMINI_* configuration in Nano Banana/Gemini mode)..env - : Gemini REST call encapsulation (connectivity check + PNG generation + current limiting retry).
scripts/nano_banana_client.py - : Nano Banana connectivity check CLI (no image generation).
scripts/nano_banana_check.py - : Nano Banana PNG generation CLI (convenient for independent prompt debugging).
scripts/nano_banana_generate_png.py
Evaluation Criteria
Focus on checking 6 dimensions:
- Text readability (font size threshold)
- Node overlap (overlap ratio)
- Arrow integrity (valid endpoints, number of crossings)
- Canvas overflow (out of bounds/close to edge)
- Visual balance (center of gravity offset)
- Overall aesthetics (local proxy evaluation based on rendered products)
Hard threshold (must be met, otherwise regarded as P0):
- Text must not overflow/be occluded: Node text should not exceed the node boundary, nor should it be covered by connections (reduce risk through draw.io element hierarchy: group bottom layer, connection middle layer, node top layer).
Additional enhanced dimensions (closer to "reduced print readability/reviewer perception"):
- Long diagonal connection penalty (encourage clearer hierarchy and alignment)
- Connection crossing/close to node penalty (reduce the risk of text crossing/close to text)
- Connection label reduced print readability access control (font size of edge label and equivalent font size after reduced printing)
- Node text crowding proxy (prompt to shorten text or enlarge nodes)
AI autonomous evaluation mode (offline protocol)
- Trigger: Set
config.yaml:evaluation.evaluation_mode=ai - Behavior: The script outputs +
ai_eval_request.md(andai_eval_response.json+ai_tex_request.mdin TEX scenarios) templates; the host AI can make semantic judgments based on spec+config+PNG/TEX and write back the response; if the response is missing or illegal, the script automatically falls back to heuristic evaluation to ensure the process can run.ai_tex_response.json
Failure Handling
- When draw.io CLI is unavailable:
- You can explicitly specify the draw.io CLI executable file path (or command name that can be parsed by PATH) in ;
config.yaml:renderer.drawio.cli_path - Use internal rendering fallback by default and give a strong prompt (internal rendering is available, but the final delivery quality is usually not as good as CLI export);
- If , it will fail directly and prompt to install draw.io.
config.yaml:renderer.allow_internal_fallback=false
- You can explicitly specify the draw.io CLI executable file path (or command name that can be parsed by PATH) in
- When spec verification fails: Return an error immediately and indicate the field path.
Maintainer Self-check
- The version number is only recorded in .
config.yaml:skill_info.version - After modifying the script, run at least 1 set of examples ().
references/spec_examples/*.yaml - When adding/adjusting output fields, update the README and CHANGELOG synchronously.
Delivery and Self-check (must pass before delivery)
- A4/screen readable (no zoom required)
- Main flow is clear (top→bottom or left→right)
- Color matching ≤ 3 main tones (auxiliary gray is allowed)
- Node naming is consistent with the main text
- Output includes and at least one embeddable format (svg or png)
schematic.drawio - Connection labels are readable (equivalent font size after reduced printing ≥ 10px)