用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/tomes --skill parser-generator命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
> Use when this capability is needed.
Use when writing kernel, account, or note MASM code that reads from or writes to the advice provider (advice stack / advice map) — validate advice data.
Use when writing a Rust test that exercises a failure path or a MASM test that expects a `panic` / `assert` — assert on the specific expected error variant or error code.
基于 SOC 职业分类
正在显示 SKILL.md
| name | parser-generator |
| description | | Use when this capability is needed. |
Generate complete, production-ready parsers for scientific instrument data files.
Always start by analyzing the example input file:
python scripts/analyze_file.py <path_to_example_file>
This script:
Example output:
============================================================
FILE ANALYSIS: example_data.xlsx
============================================================
format: excel
shape: (150, 12)
suggested_schema: plate-reader
measurement_indicators: ['absorbance', 'well', 'plate']
============================================================
✅ RECOMMENDED SCHEMA: plate-reader
============================================================
Review available schemas if auto-detection needs override:
# From within allotropy repository
python scripts/list_schemas.py [optional_filter]
# Use --verbose for detailed output with schema paths
python scripts/list_schemas.py --verbose
The script dynamically scans your local allotropy repository for all available schemas and shows:
Use the create_parser.py script to generate the complete parser:
python scripts/create_parser.py <parser_name> <schema_regex> --display_name "Vendor Instrument" --detection_modes "Absorbance, Fluorescence"
The --detection_modes flag sets the SUPPORTED_DETECTION_MODES class attribute, which populates the instruments table. Use comma-separated values for multiple modes (e.g. "Absorbance, Fluorescence, Luminescence"). Omit for instruments without detection (liquid handlers).
src/allotropy/parsers/{parser_name}/
├── __init__.py # Exports parser class
├── {parser_name}_parser.py # VendorParser subclass
├── {parser_name}_reader.py # File format parser
├── {parser_name}_structure.py # Dataclasses and factories
├── constants.py # Constants (if needed)
└── README.md # Documentation
tests/parsers/{parser_name}/
├── __init__.py
├── test_{parser_name}_parser.py # Test file
└── testdata/
└── example.xlsx # Example test file
Based on file format detection:
Excel files:
read_excel with calamine engineText files:
[Section] patterns)SectionLinesReader or read_csvCreate dataclasses for:
Header - Metadata from file headerMeasurement - Individual measurement datacreate_metadata() - Build Metadata objectcreate_measurement_groups() - Build MeasurementGroup listcreate_calculated_data() - Build calculated data (if applicable)Generate VendorParser subclass with:
DISPLAY_NAME - User-friendly instrument nameRELEASE_STATE - Start with ReleaseState.WORKING_DRAFTSUPPORTED_EXTENSIONS - File extensions (from analysis)SUPPORTED_DETECTION_MODES - Detection modes the parser supports (e.g. "Absorbance, Fluorescence") or None for instruments without detection (e.g. liquid handlers). This populates the "Supported Detection Modes" column in the supported instruments table.SCHEMA_MAPPER - Reference to schema mappercreate_data() - Orchestrate reader + structure → DataThe schema mapper defines the intermediate Data structure and maps it to Allotrope models.
Reuse existing mapper:
from allotropy.allotrope.schema_mappers.adm.{technique}.{org}.{year}.{month}.{technique} import (
Data,
Mapper,
)
Conform your create_data() to return the expected Data structure.
This is rare - most techniques have existing mappers. If needed:
Mapper.map_model() methodGenerate test file:
# tests/parsers/{parser_name}/test_{parser_name}_parser.py
def test_to_allotrope_{parser_name}() -> None:
test_file = "testdata/example.xlsx"
expected_file = "testdata/example.json"
run_allotropy(test_file, expected_file)
Run tests:
hatch run test:pytest tests/parsers/{parser_name}/
Add to src/allotropy/parser_factory.py:
from allotropy.parsers.{parser_name}.{parser_name}_parser import {ParserName}Parser
Vendor enum:class Vendor(Enum):
YOUR_INSTRUMENT = "YOUR_INSTRUMENT"
_VENDOR_TO_PARSER mapping:_VENDOR_TO_PARSER: dict[Vendor, type[VendorParser]] = {
Vendor.YOUR_INSTRUMENT: YourInstrumentParser,
# ... existing parsers
}
analyze_file.pylist_schemas.pycreate_parser.pySUPPORTED_DETECTION_MODES to the correct value for the instrumenttestdata/parser_factory.pyhatch run scripts:update-instrument-table to regenerate the supported instruments tableRELEASE_STATE when stableread_excel, SeriesData, quantity_or_none, etc.plate-readerpcr (qpcr or dpcr)solution-analyzercell-countingspectrophotometryelectrophoresisliquid-chromatographybinding-affinityflow-cytometryIMPORTANT: Never manually generate expected JSON output files using allotrope_from_file() directly. The test framework uses a UUID mocking mechanism that replaces random UUIDs with deterministic test IDs (e.g., BECKMAN_PHARMSPEC_TEST_ID_0). Manually generated JSON will have random UUIDs that won't match the test IDs at comparison time.
Correct procedure to generate expected output for new test data files:
.xls, .xlsx, .csv) in the tests/parsers/{parser_name}/testdata/ directory.json file manually--overwrite flag — the framework will write the expected output:
hatch run test_all.py3.10:pytest tests/parsers/{parser_name}/ --overwrite -q
AssertionError: Missing expected output file ... writing expected output because 'write_actual_to_expected_on_fail=True' — this is expected behavior, it means the JSON was writtenhatch run test_all.py3.10:pytest tests/parsers/{parser_name}/ -q
The test framework (in src/allotropy/testing/utils.py) uses mock_uuid_generation(vendor.name) which patches the UUID generator to produce sequential test IDs like {VENDOR_NAME}_TEST_ID_0, {VENDOR_NAME}_TEST_ID_1, etc. This ensures deterministic output for comparison.
After generating the JSON, manually inspect it to verify all expected data from the original input file is present and correct. The test framework only guarantees the parser ran without errors — it cannot verify that all data was captured. Check:
Schema detection fails: Manually specify schema after reviewing list_schemas.py output
File format unclear: Look at similar parsers in the repository
Mapping errors: Check schema mapper Data structure requirements
Tests fail: Validate ASM output structure matches expected schema
Source: Benchling-Open-Source/allotropy — distributed by TomeVault.