nsfc-schematic
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNSFC 原理图生成器
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
用户至少提供其一:
- :结构化图规格文件(推荐,最可控)
spec_file - :单个标书文件(如
proposal_file或main.tex)extraTex/*.tex - :标书目录(自动搜索
proposal_path).tex
可选:
- :优化轮次(默认见
rounds)config.yaml:evaluation.max_rounds - :渲染后端(默认
renderer;仅当用户主动提及 Nano Banana/Gemini 图片模型时才允许使用drawio,该模式仅输出 PNG)nano_banana - :输出目录(可选;默认使用
output_dir,相对当前工作目录)config.yaml:output.dirname - :配置文件路径(可选;默认使用技能自带
config;用于为某个项目单独覆盖nsfc-schematic/config.yaml等参数)output.hide_intermediate - :自然语言机制描述(仅用于“规划模式”;由
context生成规划草案与 spec 草案)plan_schematic.py - :图类型模板 id/family(高级选项;默认“纯 AI 规划”不需要也不建议设置)
template_ref
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
在 下生成(每次运行会创建隔离的 ,避免历史残留混入):
output_dirrun_*/round_*- :可编辑源文件
schematic.drawio - :推荐用于 LaTeX/Word 嵌入(优先矢量;无 draw.io CLI 时降级为 PNG→PDF 栅格)
schematic.pdf - :矢量图(更适合网页/幻灯片;draw.io SVG 可能包含 foreignObject,部分工具链会丢字)
schematic.svg - :预览图
schematic.png - Nano Banana / Gemini PNG-only 模式:交付 4K + 体积显著更小的
schematic.png(默认将 4K 图下采样并压缩,适合嵌入标书 PDF;不生成schematic_compacted.png).drawio/.svg/.pdf - :中间产物目录(默认开启隐藏;目录名可配置)
.nsfc-schematic/- :latest 优化记录(每次运行覆盖更新)
optimization_report.md - :latest 使用的 spec(便于复现/追溯)
spec_latest.yaml - /
config_used_best.yaml:latest 最佳轮次复现证据evaluation_best.json - :本次运行目录(含
runs/run_YYYYMMDDHHMMSS(__tag)/、每轮评估与渲染产物;当使用round_*时会附加--run-tag)__tag - :
ai/的闭环工作区(stop_strategy=ai_critic、ACTIVE_RUN.txt、{run}/ai_pack_round_XX/、ai_critic_request.md)ai_critic_response.yaml - :自动迁移/收纳的历史残留(如旧版输出的
legacy/、run_*、spec*.yaml、config_*.yaml等)evaluation_*.json
默认情况下, 根目录只保留交付文件(drawio/svg/png/pdf)与隐藏目录 ,避免中间文件污染用户工作目录。
output_dir.nsfc-schematic/兼容模式:
- 如需恢复旧行为(中间文件与 直接写在
run_*根目录),设置output_dir。config.yaml:output.hide_intermediate=false
每个 默认会生成以下“可追溯证据”(可通过 关闭):
round_*/config.yaml:evaluation.*- :主评估器结果(含
evaluation.json)score_base/score_penalty/score_total - :布局诊断(节点/分组几何信息)
layout_debug.json - :连线诊断(edge id、kind、route、waypoints)
edge_debug.json - :主评估的纯度量证据
measurements.json - :结构/视觉/可读性维度证据(由 critique 汇总)
dimension_measurements.json - :多维度批判性自检证据(
critique_structure.json / critique_visual.json / critique_readability.json;仅在启发式评估或 AI 回退路径下生成,避免与 AI 口径重复扣分)evaluation.multi_round_self_check - :每轮有限候选对比(
_candidates/)evaluation.exploration.candidates_per_round
当 时(可选增强),脚本会输出离线协议文件(脚本不在本地调用外部模型):
config.yaml:evaluation.evaluation_mode=ai- +
round_*/_candidates/cand_*/ai_eval_request.md:AI 评估请求/响应(主评估)ai_eval_response.json - +
run_*/ai_tex_request.md:当输入来自 TEX 且未提供 spec_file 时,用于“AI 直接读 TEX → 生成 spec 草案”的离线请求/响应(如未响应则自动降级为正则抽取)ai_tex_response.json
规划模式交付:
- :规划草案(由宿主 AI 写入;脚本负责生成请求协议并在复跑时做合法性校验)
output_dir/schematic-plan.md - (可选):如需额外复制一份到当前工作目录便于审阅,使用
schematic-plan.mdplan_schematic.py --also-write-workspace-plan
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(兼容旧版)
Spec v2 (backward compatible with old versions)
- 现在为可选:缺失时脚本按
node.id生成稳定 id(可复现)。group + label + index - 支持显式边协议:
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: 输入数据- 渲染优先级:
- 提供 :严格按显式边输出;
edges - 未提供 :回退到
edges(layout.auto_edges)。minimal|off
- 提供
- 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
- 拥挤优先改 spec(缩短文案/合并节点/减少节点),不要靠缩字号硬过阈值。
- 只有 overflow 风险时才减字号;若字号偏小且无 overflow,应增字号。
- 配色干扰优先改 kind 分配,不用黑白方案掩盖结构问题。
- 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)
开始前读取 ,以此作为执行单一真相来源:
config.yaml- :画布尺寸、字体、渲染行为
renderer - :draw.io CLI 缺失时的提示/(可选)自动安装策略
renderer.drawio - :自动布局参数
layout - :未提供显式 edges 时的自动连线策略(
layout.auto_edges)minimal|off - :图类型模板(高级选项;默认不启用;模型画廊仅用于学习,见
layout.template_ref)references/models/templates.yaml - :图内标题开关与顶部预留(默认关闭图内标题,推荐外部图注)
layout.title - :节点文案“自动扩容”策略(避免导出后文字溢出/遮挡)
layout.text_fit - :当节点/分组被自动扩容后,是否自动扩展画布以避免越界
layout.auto_expand_canvas - :画布拟合策略(可选按内容边界收缩;并可将内容 bbox 居中以减少单侧留白)
layout.canvas_fit - :路由避让参数(更保守的障碍 padding、避让分组标题栏)
layout.routing - :连线标签字号(edge label 不会自动跟随
layout.font.edge_label_size,需单独配置)node_label_size - :配色方案
color_scheme - :评分阈值、停止策略(stop_strategy)、权重与多轮探索参数
evaluation - :评估模式(默认
evaluation.evaluation_mode;heuristic为可选增强:输出离线 AI 协议文件并消费宿主 AI 响应;无响应则自动降级)ai - :连线标签字号门禁阈值(含缩印等效字号检查)
evaluation.thresholds.min_edge_font_px/warn_edge_font_px - :Spec 安全变体(默认关闭;只对 label 做 wrap/truncate/candidates,用于缓解长文案导致的拥挤/溢出)
evaluation.spec_variants - /
output.hide_intermediate:中间文件隐藏策略与目录名output.intermediate_dir - :最多保留最近 N 次
output.max_history_runs(仅在 hide_intermediate=true 时生效)run_* - :实例级覆盖(白名单:
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} - :图类型模板库路径(默认
planning.models_file)references/models/templates.yaml - :规划模式(
planning.planning_mode;默认ai|template:纯 AI 规划协议)ai
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)
当用户首次为标书生成原理图时,推荐先“规划 → 审阅 → 再生成”:
- 调查标书并生成“规划请求协议”(脚本会综合提取“立项依据 + 研究内容/技术路线”,并生成模型画廊供学习;不要求选模板):
bash
python3 nsfc-schematic/scripts/plan_schematic.py \
--proposal /path/to/proposal/ \
--output ./schematic_plan/(兼容旧流程)如需让脚本按确定性规则直接生成草案(模板规划),使用:
bash
python3 nsfc-schematic/scripts/plan_schematic.py \
--mode template \
--proposal /path/to/proposal/ \
--output ./schematic_plan/或使用自然语言描述:
bash
python3 nsfc-schematic/scripts/plan_schematic.py \
--context "用一句话/一段话描述机制与模块关系..." \
--output ./schematic_plan/- 宿主 AI 纯规划:根据 的要求,写出:
./schematic_plan/.nsfc-schematic/planning/plan_request.md
./schematic_plan/schematic-plan.md./schematic_plan/spec_draft.yaml
(视觉学习可选)规划脚本会(尽力)在 目录下生成“模型画廊”(用于学习优秀结构/风格):
--output- :骨架/模式图(推荐优先看)
./schematic_plan/.nsfc-schematic/planning/models_simple_contact_sheet.png - :完整参考图(用于风格与细节补全)
./schematic_plan/.nsfc-schematic/planning/models_contact_sheet.png
- 再次运行规划脚本进行合法性校验(脚本将校验 spec 结构,并给出 P0/WARN 提示):
bash
python3 nsfc-schematic/scripts/plan_schematic.py \
--proposal /path/to/proposal/ \
--output ./schematic_plan/- 审阅 与
schematic_plan/schematic-plan.md:确认模块划分、节点清单、连接关系与布局建议是否合理。schematic_plan/spec_draft.yaml- 如需手动起草规划草案,可参考:
nsfc-schematic/references/plan_template.md
- 如需手动起草规划草案,可参考:
- 用 进入多轮生成与优化:
generate_schematic.py
bash
python3 nsfc-schematic/scripts/generate_schematic.py \
--spec-file ./schematic_plan/spec_draft.yaml \
--output-dir ./schematic_output/ \
--rounds 5When 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 5生成流程(默认入口)
Generation 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 5流程拆解:
- 解析 spec()并自动补全布局。
spec_parser.py - 生成 draw.io XML()。
schematic_writer.py - 预检(P0):对 做 XML well-formed 校验;失败则立即停止并给出可读错误。
.drawio - 渲染 SVG/PNG/PDF()。
render_schematic.py - 评估图质量(),并增强“近空白渲染/内容丢失”的识别与分级。
evaluate_schematic.py - 多维度自检():结构/视觉/可读性独立证据落盘,并按缺陷线性扣分得到
evaluate_dimension.py。score_total - 记录每轮结果并导出 best round。
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.
生成流程(Nano Banana / Gemini PNG-only,仅当用户主动要求)
Generation Process (Nano Banana / Gemini PNG-only, only when users actively request)
硬规则:只有当用户明确提出要用 Nano Banana/Gemini 图片模型(例如用户说“用 Nano Banana”“用 Gemini 出图”“不用 draw.io”)时,才允许启用该模式;否则必须保持默认 draw.io 流程。
前置条件:在项目根目录 (或系统环境变量)配置并可连通:
.env- (示例:
GEMINI_BASE_URL)https://generativelanguage.googleapis.com/v1beta - (Gemini API Key)
GEMINI_API - (示例:
GEMINI_MODEL)gemini-3.1-flash-image-preview
建议先做连通性检查(不会输出图片):
bash
python3 nsfc-schematic/scripts/nano_banana_check.py如你不是在项目根目录执行,可显式指定 :
.envbash
python3 nsfc-schematic/scripts/nano_banana_check.py --dotenv /path/to/.env生成 PNG(默认 ;仅输出 ):
--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 5说明:
- Nano Banana 模式下脚本会自动关闭 SVG/PDF 导出,并在每轮只生成 1 个候选(避免成本乘法);多方案对比请用 多线程并行。
parallel-vibe - 该模式的 prompt 会从 spec(分组/节点/edges)确定性构建,并包含“打印级文字排版”硬约束(禁止文字扭曲/旋转/艺术字等);优化时优先改 spec 的标签长度、分组边界与边关系,保证“缩印可读”。
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".
评估-优化循环(默认:AI 闭环)
Evaluation-Optimization Loop (Default: AI Closed Loop)
- 默认配置:
evaluation.stop_strategy=ai_critic - 脚本行为:
- 每次运行只推进 1 轮,生成证据包后暂停,等待宿主 AI 响应
- 自动打分与落盘证据(+
evaluation.json+*_debug.json)measurements*.json - 宿主 AI 写回 后,resume 即推进下一轮;写
ai_critic_response.yaml则导出最终交付文件action: stop
- 如需无人值守的自动收敛,可在 覆盖为
config_local.yamlstop_strategy: plateau
- 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
多方案并行优化(parallel-vibe,可选,推荐用于“开很多 run 反复对比”)
Multi-scheme Parallel Optimization (parallel-vibe, optional, recommended for "opening many runs and comparing repeatedly")
适用:当你需要同时尝试不同的优化策略(画布/字号/间距/路由/探索种子等),避免在同一 内来回改 导致 run 混淆。
output_dirconfig_local.yaml核心策略:用 创建多个隔离工作区,每个线程各自维护一份 (仅白名单字段),并用 标记本次运行来源。
parallel-vibeoutput_dir/.nsfc-schematic/config_local.yaml--run-tag默认建议开 5 个线程(与 的“默认轮次”对齐;也更方便 1 轮就筛掉明显不优方案)。
evaluation.max_rounds=5推荐线程(示例,按常见痛点拆分):
- thread_1(结构与留白):增大 ,必要时增大画布
layout.auto.group_gap_y/node_gap_y - thread_2(可读性优先):增大 ,必要时增大画布
layout.font.node_label_size/edge_label_size - thread_3(连线与可解释性):切换 或关闭
renderer.internal_routing=straightlayout.auto_edges - thread_4(跳出局部最优):保持结构不变,仅改 (让探索抖动走另一条轨迹)
evaluation.exploration.seed
每个线程建议先跑小轮次快速筛选(如 ),择优后再回到主工作区用更高轮次精修(如 )。
--rounds 3--rounds 7Applicable: 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 自主闭环(ai_critic,离线协议)
AI Autonomous Closed Loop (ai_critic, Offline Protocol)
默认模式。每次运行只推进 1 轮,由宿主 AI 评价证据包并决定下一步。如需回退到无人值守的自动收敛,可在 中覆盖 。
config_local.yamlstop_strategy: plateau- 运行生成脚本(每次只推进 1 轮):
bash
python3 nsfc-schematic/scripts/generate_schematic.py \
--spec-file ./schematic_plan/spec_draft.yaml \
--output-dir ./schematic_output/- 找到 request 与证据包(脚本会提示路径;默认在隐藏目录内):
- :当前闭环 run(用于 resume)
output_dir/.nsfc-schematic/ai/ACTIVE_RUN.txt - :宿主 AI 的指令
output_dir/.nsfc-schematic/ai/<run>/ai_critic_request.md - :证据包(含
output_dir/.nsfc-schematic/ai/<run>/ai_pack_round_XX/+schematic.png等;若evaluation.json还会包含renderer=nano_banana)nano_banana_prompt.md
- 宿主 AI 写回响应:
按 的协议写入:
ai_critic_request.mdoutput_dir/.nsfc-schematic/ai/<run>/ai_critic_response.yaml
Nano Banana(Gemini PNG-only)+ ai_critic 额外约定:
- 宿主 AI 应以 直接读图()的视觉判断 为主;
schematic.png仅作参考。evaluation.json/*_debug.json - 宿主 AI 需要判断当前“整体风格”(构图/线条/配色/质感)是否已经足够好:
- 若足够好:写 ;下一轮会把上一轮
style_continuity: true作为参考图传入 Gemini,保证风格延续。schematic.png - 若仍需大改:写 ;下一轮不传参考图(避免把坏风格固化)。
style_continuity: false
- 若足够好:写
- 若认为配色仍需优化,可写 ;脚本会自动拼到下一轮 prompt 里。
nano_banana_color_advice
最小示例(通用):
yaml
version: 1
based_on_round: 1
action: config_only # spec_only|config_only|both|stop
reason: "一句话说明为什么这样改"
config_local:
layout:
font:
node_label_size: 28最小示例(仅 Nano Banana,可选字段):
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:
再次运行 即可自动消费响应、推进下一轮;当写入 后脚本会清除 并导出最终交付文件。
generate_schematic.pyaction: stopACTIVE_RUN.txtDefault 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.txt脚本职责
Script Responsibilities
- :解析/校验 spec,补全自动布局,校验边。
scripts/spec_parser.py - :将规范化 spec 转为 draw.io XML。
scripts/schematic_writer.py - :优先 draw.io CLI 渲染;缺失时内部兜底渲染。
scripts/render_schematic.py - :生成/消费 AI 评估离线协议(ai_eval_request.md / ai_eval_response.json),不在脚本内调用外部模型。
scripts/ai_evaluate.py - :生成/消费 AI TEX 提取离线协议(ai_tex_request.md / ai_tex_response.json),不在脚本内调用外部模型。
scripts/ai_extract_tex.py - :主评估的“纯度量采集层”(几何/路由/像素 proxy),保留用于启发式评估与降级兜底。
scripts/measure_schematic.py - :多维度自检的“纯度量采集层”(structure/visual/readability),保留用于启发式自检与降级兜底。
scripts/measure_dimension.py - :启发式评估(兜底);启用
scripts/evaluate_schematic.py时输出离线 AI 协议并消费宿主 AI 的评审响应(缺失时自动回退启发式)。evaluation_mode=ai - :启发式多维度自检(用于 penalty 扣分;当 AI 主评估生效时默认跳过,避免口径重复)。
scripts/evaluate_dimension.py - :确定性正交路由(waypoints),用于渲染兜底、drawio 写入与评估口径对齐。
scripts/routing.py - :从 TEX 抽取术语用于初版 spec 填充。
scripts/extract_from_tex.py - :一键编排多轮迭代。
scripts/generate_schematic.py - :
scripts/env_utils.py解析与向上查找(用于 Nano Banana/Gemini 模式读取 GEMINI_* 配置)。.env - :Gemini REST 调用封装(连通性检查 + PNG 生成 + 限流重试)。
scripts/nano_banana_client.py - :Nano Banana 连通性检查 CLI(不生成图片)。
scripts/nano_banana_check.py - :Nano Banana PNG 生成 CLI(便于单独调试 prompt)。
scripts/nano_banana_generate_png.py
- : 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
重点检查 6 个维度:
- 文字可读性(字号阈值)
- 节点重叠(交叠比例)
- 箭头完整性(端点有效、交叉数量)
- 画布溢出(越界/贴边)
- 视觉平衡(重心偏移)
- 整体美观(基于渲染产物的本地代理评估)
硬门槛(必须满足,否则视为 P0):
- 文字不得溢出/被遮挡:节点文案不应超出节点边界,也不应被连线覆盖(通过 draw.io 元素层级:分组底层、连线中层、节点顶层 来降低风险)。
额外增强维度(更贴近“缩印可读性/审稿人观感”):
- 长对角线连线惩罚(鼓励更清晰的层次与对齐)
- 连线穿越/贴近节点惩罚(减少穿字/贴字风险)
- 连线标签缩印可读性门禁(edge label 的字号与缩印后等效字号)
- 节点文案拥挤度 proxy(提示缩短文案或增大节点)
AI 自主评估模式(离线协议)
- 触发:设置
config.yaml:evaluation.evaluation_mode=ai - 行为:脚本输出 +
ai_eval_request.md(以及 TEX 场景下的ai_eval_response.json+ai_tex_request.md)模板;宿主 AI 可基于 spec+config+PNG/TEX 做语义判定并写回 response;若 response 缺失或不合法,脚本自动回退到启发式评估,保证流程可跑通。ai_tex_response.json
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
- draw.io CLI 不可用时:
- 可在 显式指定 draw.io CLI 可执行文件路径(或可被 PATH 解析的命令名);
config.yaml:renderer.drawio.cli_path - 默认使用内部渲染兜底并给出强提示(内部渲染可用,但最终交付质量通常不如 CLI 导出);
- 若 ,则直接失败并提示安装 draw.io。
config.yaml:renderer.allow_internal_fallback=false
- 可在
- spec 校验失败时:立即返回错误,指出字段路径。
- 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
- 版本号仅记录在 。
config.yaml:skill_info.version - 修改脚本后至少运行 1 组示例()。
references/spec_examples/*.yaml - 新增/调整输出字段时同步更新 README 与 CHANGELOG。
- 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/屏幕可读(不依赖放大)
- 主流向清晰(上→下 或 左→右)
- 配色 ≤ 3 种主色调(允许辅助灰)
- 节点命名与正文一致
- 输出包含 与至少一种可嵌入格式(svg 或 png)
schematic.drawio - 连线标签可读(缩印后等效字号 ≥ 10px)
- 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)