FlashFormat Local Converters
Overview
Run local format conversion directly from Python scripts under skills/flashformat-local-converters/scripts/.
Avoid calling /api/v2/*; execute conversion in local shell, CI, or offline pipelines.
Quick Start
- 1. Install runtime dependency:
python -m pip install PyYAML
- 2. Run any converter script with one input channel:
--input or
--input-file or
stdin
- 3. Choose output mode:
plain text (default) or
--json
- 4. Optionally write result to file:
INLINECODE7
Script Map
- -
scripts/yaml_to_json.py: Convert YAML to JSON, support --indent and INLINECODE10 - INLINECODE11 : Convert JSON to YAML, support
--sort-keys and INLINECODE13 - INLINECODE14 : Strip Markdown syntax into readable text
- INLINECODE15 : Minify JSON to one-line payload
- INLINECODE16 : Apply conservative YAML whitespace/indent fixes with validation
Unified CLI Contract
- - Input priority:
--input > --input-file > INLINECODE19 - Output target:
stdout by default, or INLINECODE21 - JSON mode payloads:
{"ok": true, "tool": "...", "output": "..."}
{"ok": false, "tool": "...", "error": "..."}
- - Plain mode failures write error text to
stderr and return non-zero exit code
Usage Examples
python skills/flashformat-local-converters/scripts/yaml_to_json.py --input-file in.yaml --output-file out.json
- - JSON to YAML (sorted keys):
python skills/flashformat-local-converters/scripts/json_to_yaml.py --input '{"b":2,"a":1}' --sort-keys
- - Markdown to text (stdin pipeline):
cat draft.md | python skills/flashformat-local-converters/scripts/markdown_to_text.py
- - JSON minify with structured output:
python skills/flashformat-local-converters/scripts/json_minify.py --input-file data.json --json
INLINECODE29
References
Read references/io-contracts.md when exact options, error messages, and backend logic mapping are needed.
FlashFormat 本地转换器
概述
直接从 skills/flashformat-local-converters/scripts/ 下的 Python 脚本运行本地格式转换。
避免调用 /api/v2/*;在本地 shell、CI 或离线管道中执行转换。
快速开始
- 1. 安装运行时依赖:
python -m pip install PyYAML
- 2. 使用一个输入通道运行任意转换脚本:
--input 或 --input-file 或 stdin
- 3. 选择输出模式:
纯文本(默认)或 --json
- 4. 可选地将结果写入文件:
--output-file <路径>
脚本映射
- - scripts/yamltojson.py:将 YAML 转换为 JSON,支持 --indent 和 --compact
- scripts/jsontoyaml.py:将 JSON 转换为 YAML,支持 --sort-keys 和 --compact
- scripts/markdowntotext.py:去除 Markdown 语法,提取可读文本
- scripts/jsonminify.py:将 JSON 压缩为单行负载
- scripts/yamlauto_fix.py:应用保守的 YAML 空白/缩进修复并验证
统一 CLI 约定
- - 输入优先级:--input > --input-file > stdin
- 输出目标:默认为 stdout,或使用 --output-file
- JSON 模式负载:
{ok: true, tool: ..., output: ...}
{ok: false, tool: ..., error: ...}
- - 纯文本模式失败时,将错误文本写入 stderr 并返回非零退出码
使用示例
python skills/flashformat-local-converters/scripts/yaml
tojson.py --input-file in.yaml --output-file out.json
python skills/flashformat-local-converters/scripts/json
toyaml.py --input {b:2,a:1} --sort-keys
- - Markdown 转文本(stdin 管道):
cat draft.md | python skills/flashformat-local-converters/scripts/markdown
totext.py
python skills/flashformat-local-converters/scripts/json_minify.py --input-file data.json --json
python skills/flashformat-local-converters/scripts/yaml
autofix.py --input-file broken.yaml --indent-step 2 --fix-tabs --fix-odd-indent
参考
当需要精确的选项、错误消息和后端逻辑映射时,请阅读 references/io-contracts.md。