zotero-schema
Generate Gnosi's Python and TypeScript item-type constants from the repository-pinned Zotero schema, or perform an explicitly requested pinned schema refresh. Use for mapping or generated-constant maintenance, not runtime downloads.
- License 许可
- AGPL-3.0
- 所属仓库
- ismigar/Gnosi
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- zotero-schema
- description
- Generate Gnosi's Python and TypeScript item-type constants from the repository-pinned Zotero schema, or perform an explicitly requested pinned schema refresh. Use for mapping or generated-constant maintenance, not runtime downloads.
02 资源文件 4
- 参考文档schema.json384.7 KB
- 脚本scripts/build_constants.py11.2 KB
- 脚本scripts/build_reference_catalog.py6.3 KB
- 脚本scripts/refresh_schema.py2.2 KB
03 SKILL.md 正文
Skill: Zotero Schema
The source of truth for Gnosi item types and fields, derived from Zotero's
official data schema. Gnosi does not depend on the Zotero application. It
vendors factual data from schema.json to avoid manually maintaining
Zotero-to-CSL mappings and multilingual labels.
ID: ZOTERO-SCHEMA-20260528 Stack: Python 3.10+ standard library; Node is not required Pinned version:
42· commit62e983a2e575fe9b9a3677ad7c9772080b67a1e4(2026-03-16) Source: https://github.com/zotero/zotero-schema
Generated outputs
The build reads repository-pinned schema.json, never a
runtime download, and writes:
| Generated file | Consumer |
|---|---|
backend/services/zotero_schema.py |
vault_routes.py, replacing hard-coded _RECURSOS_TYPE_TO_CSL |
frontend/src/generated/zoteroSchema.ts |
Typed frontend consumers through components/Vault/zoteroSchema.ts |
Both Python and TypeScript expose the same constants:
SCHEMA_VERSION: current schema version, currently42.SCHEMA_SOURCE_SHA: first 16 characters of the pinned file SHA-256.ALL_ITEM_TYPES: sorted list of 40 types such asbook,journalArticle,preprint, anddataset.ZOTERO_TO_CSL_TYPE:{zoteroType: cslType}.ZOTERO_TYPE_LABELS:{locale: {zoteroType: translatedLabel}}forca-AD,es-ES,en-GB, anden-US.LABEL_TO_ZOTERO_TYPE: inverse labels used to resolve legacy frontmatter that stores translated labels instead of canonical keys.
Commands
# Regenerate constants from the local schema deterministically.
python3 pipeline/skills/zotero_schema/scripts/build_constants.py
# Refresh schema.json to the newest zotero/zotero-schema version.
python3 pipeline/skills/zotero_schema/scripts/refresh_schema.py
# Refresh to a specific commit for a controlled hotfix or downgrade.
python3 pipeline/skills/zotero_schema/scripts/refresh_schema.py --ref <SHA>
After refresh_schema.py, always run build_constants.py and update the
"Pinned version" line in this file.
Validation
backend/tests/test_zotero_schema.py verifies in CI:
- Build idempotency: rebuilding from the current schema exactly matches committed output.
- Python/TypeScript consistency: both outputs have identical
ALL_ITEM_TYPESandZOTERO_TO_CSL_TYPEkeys. - Coverage: every current Vault
Item Typeresolves either directly throughZOTERO_TO_CSL_TYPEor throughLABEL_TO_ZOTERO_TYPE['ca-AD'].
A Zotero schema format change fails test 1. An unsupported free-form frontmatter value fails test 3 and lists orphaned values.
Restrictions and edge cases
- License:
zotero/zotero-schemadoes not explicitly declare a license. The schema represents factual data-model information. Generated headers attribute the source. Review this decision if Zotero later clarifies its licensing. - Deterministic build: sort keys alphabetically for stable diffs even when upstream JSON ordering changes.
- Strict pinning: update only through
refresh_schema.pyand an explicit commit. Never download the schema during runtime or CI. - Multiple CSL types: a Zotero type can rarely list more than one
csl.typesvalue. Select the first alphabetically and emit a stderr warning. - Missing locales: fall back to the canonical English key when a locale lacks a label.
- Legacy frontmatter: existing Vault pages can store Catalan labels such
as
"Article de revista acadèmica"rather than"journalArticle".LABEL_TO_ZOTERO_TYPE['ca-AD']supports those persisted values without a frontmatter migration. - Frontend output: generate the large catalogue inside
frontend/src/generated/so source guardrails recognize it as generated. Keepcomponents/Vault/zoteroSchema.tsas a small stable re-export for existing consumers. Never regenerate production JavaScript.
Learning history
| Date | Learning | Resolution |
|---|---|---|
| 2026-05-28 | Python and JavaScript maintained separate hard-coded type maps, so new Zotero types drifted. | Added this skill as a single pinned schema source with deterministic Python and JavaScript generation. |
| 2026-08-29 | The generated frontend catalogue remained a 517-line production JavaScript file during the strict TypeScript migration. | Moved deterministic output to frontend/src/generated/zoteroSchema.ts, added explicit readonly types and retained a small stable TypeScript facade. |
04 同仓库更多 Skills
zotero-sync-compatibility
Preserve the historical Zotero reference-table configuration path after Gnosi replaced bidirectional Zotero synchronization with its native reference manager.
vault-core
Preserve Gnosi vault identifiers, internal links and active-vault context during file or metadata changes. Use for vault integrity work, not blanket normalization or cleanup of user documents.
translate-row
Translate configured table-row fields and Markdown into language children, updating existing translations in place. Use for the explicit translate-row action or maintenance of its provider adapters.
translate-page
Translate a Vault page title and Markdown body into language children, updating existing translations and preserving Gnosi directives. Use for the explicit translate-page action or Markdown segmentation maintenance.
technical-documentation
Generate and validate Gnosi's engineering portal from reviewed guides and deterministic source catalogs. Use for source-traceable documentation updates and pre-PR gates; never translate generated catalogs with a model.
suggest-connections
Maintain Gnosi's evidence-backed Brain connection proposal queue and graph overlay. Use for proposal generation or review behavior, not automatic note creation or unrequested model calls.