mednotes-opencode 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/agents/med-chat-triager.md +204 -0
- package/.opencode/agents/med-flashcard-maker.md +63 -0
- package/.opencode/agents/med-knowledge-architect.md +230 -0
- package/.opencode/agents/med-link-graph-curator.md +177 -0
- package/.opencode/agents/med-publish-guard.md +62 -0
- package/.opencode/commands/flashcards.md +25 -0
- package/.opencode/commands/mednotes/create.md +25 -0
- package/.opencode/commands/mednotes/enrich.md +27 -0
- package/.opencode/commands/mednotes/fix-wiki.md +27 -0
- package/.opencode/commands/mednotes/history.md +22 -0
- package/.opencode/commands/mednotes/link-body.md +25 -0
- package/.opencode/commands/mednotes/link-related.md +27 -0
- package/.opencode/commands/mednotes/link.md +27 -0
- package/.opencode/commands/mednotes/pdf-library.md +27 -0
- package/.opencode/commands/mednotes/process-chats.md +23 -0
- package/.opencode/commands/mednotes/setup.md +21 -0
- package/.opencode/commands/mednotes/status.md +27 -0
- package/.opencode/commands/mednotes/telemetry.md +27 -0
- package/.opencode/commands/report.md +26 -0
- package/.opencode/mednotes/AGENTS.md +57 -0
- package/.opencode/mednotes/agents/med-chat-triager.md +197 -0
- package/.opencode/mednotes/agents/med-flashcard-maker.md +56 -0
- package/.opencode/mednotes/agents/med-knowledge-architect.md +224 -0
- package/.opencode/mednotes/agents/med-link-graph-curator.md +171 -0
- package/.opencode/mednotes/agents/med-publish-guard.md +55 -0
- package/.opencode/mednotes/contracts/.gitkeep +1 -0
- package/.opencode/mednotes/contracts/agents.json +116 -0
- package/.opencode/mednotes/contracts/opencode-plugin.json +70 -0
- package/.opencode/mednotes/docs/agent-prompt-hardening.md +567 -0
- package/.opencode/mednotes/docs/agent-role-contracts.md +94 -0
- package/.opencode/mednotes/docs/anki-mcp-twenty-rules.md +214 -0
- package/.opencode/mednotes/docs/anki-templates/README.md +39 -0
- package/.opencode/mednotes/docs/anki-templates/cloze.back.html +23 -0
- package/.opencode/mednotes/docs/anki-templates/cloze.front.html +14 -0
- package/.opencode/mednotes/docs/anki-templates/qa.back.html +24 -0
- package/.opencode/mednotes/docs/anki-templates/qa.front.html +14 -0
- package/.opencode/mednotes/docs/anki-templates/style.css +182 -0
- package/.opencode/mednotes/docs/atomicity-splitting-policy.md +113 -0
- package/.opencode/mednotes/docs/extension-docs.md +40 -0
- package/.opencode/mednotes/docs/flashcard-ingestion.md +278 -0
- package/.opencode/mednotes/docs/knowledge-architect.md +208 -0
- package/.opencode/mednotes/docs/merge-policy.md +110 -0
- package/.opencode/mednotes/docs/public-vocabulary.md +104 -0
- package/.opencode/mednotes/docs/semantic-linker.md +141 -0
- package/.opencode/mednotes/docs/taxonomy-policy.md +90 -0
- package/.opencode/mednotes/docs/triage-policy.md +187 -0
- package/.opencode/mednotes/docs/vault-version-control.md +758 -0
- package/.opencode/mednotes/docs/vocabulary-db-recovery.md +58 -0
- package/.opencode/mednotes/docs/workflow-output-contract.md +779 -0
- package/.opencode/mednotes/hooks/hooks.json +79 -0
- package/.opencode/mednotes/package-lock.json +6361 -0
- package/.opencode/mednotes/package.json +15 -0
- package/.opencode/mednotes/pyproject.toml +48 -0
- package/.opencode/mednotes/scripts/bootstrap_windows_python_uv.cmd +13 -0
- package/.opencode/mednotes/scripts/bootstrap_windows_python_uv.ps1 +172 -0
- package/.opencode/mednotes/scripts/enrich_notes.py +23 -0
- package/.opencode/mednotes/scripts/full_reset_windows_python_uv.cmd +13 -0
- package/.opencode/mednotes/scripts/hooks/antigravity_hook_status.mjs +212 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/antigravity.mjs +169 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/harness_payload.mjs +103 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/opencode_plugin.mjs +341 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/opencode_user_config_sync.mjs +177 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/anki_preflight.mjs +214 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/cli.mjs +143 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/diagnostics.mjs +11 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/domain/agent_directive_core.mjs +160 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/fsm_directive.mjs +1470 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/hook_errors.mjs +120 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/retention.mjs +114 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/runtime.mjs +174 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/telemetry_capture.mjs +511 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook/vault_guard.mjs +624 -0
- package/.opencode/mednotes/scripts/hooks/mednotes_hook.mjs +5 -0
- package/.opencode/mednotes/scripts/mednotes/_runtime_paths.py +24 -0
- package/.opencode/mednotes/scripts/mednotes/anki_model_validator.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/capture_extension_diff.py +1562 -0
- package/.opencode/mednotes/scripts/mednotes/feedback_report.py +16 -0
- package/.opencode/mednotes/scripts/mednotes/flashcard_index.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/flashcard_pipeline.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/flashcard_report.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/flashcard_sources.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/obsidian/README.md +6 -0
- package/.opencode/mednotes/scripts/mednotes/obsidian_note_utils.py +20 -0
- package/.opencode/mednotes/scripts/mednotes/pdf_library/cli.py +16 -0
- package/.opencode/mednotes/scripts/mednotes/project_fsm.py +229 -0
- package/.opencode/mednotes/scripts/mednotes/setup_telemetry_email.py +404 -0
- package/.opencode/mednotes/scripts/mednotes/sync_anki_twenty_rules.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/sync_opencode_user_config.py +36 -0
- package/.opencode/mednotes/scripts/mednotes/wiki/cli.py +20 -0
- package/.opencode/mednotes/scripts/mednotes/wiki_graph.py +18 -0
- package/.opencode/mednotes/scripts/mednotes/wiki_tree.py +134 -0
- package/.opencode/mednotes/scripts/reset_windows_python_uv.ps1 +625 -0
- package/.opencode/mednotes/scripts/run_python.mjs +109 -0
- package/.opencode/mednotes/scripts/vault/vault_commit.ps1 +19 -0
- package/.opencode/mednotes/scripts/vault/vault_commit.sh +18 -0
- package/.opencode/mednotes/scripts/vault/vault_git.ps1 +19 -0
- package/.opencode/mednotes/scripts/vault/vault_git.py +3107 -0
- package/.opencode/mednotes/scripts/vault/vault_git.sh +18 -0
- package/.opencode/mednotes/scripts/vault/vault_precommit.ps1 +19 -0
- package/.opencode/mednotes/scripts/vault/vault_precommit.sh +18 -0
- package/.opencode/mednotes/skills/THIRD_PARTY_NOTICES.md +45 -0
- package/.opencode/mednotes/skills/create-medical-flashcards/SKILL.md +113 -0
- package/.opencode/mednotes/skills/create-medical-note/SKILL.md +90 -0
- package/.opencode/mednotes/skills/enrich-medical-note/SKILL.md +120 -0
- package/.opencode/mednotes/skills/fix-medical-wiki/SKILL.md +559 -0
- package/.opencode/mednotes/skills/link-medical-wiki/SKILL.md +224 -0
- package/.opencode/mednotes/skills/obsidian-cli/SKILL.md +118 -0
- package/.opencode/mednotes/skills/obsidian-markdown/SKILL.md +207 -0
- package/.opencode/mednotes/skills/obsidian-markdown/references/CALLOUTS.md +58 -0
- package/.opencode/mednotes/skills/obsidian-markdown/references/EMBEDS.md +63 -0
- package/.opencode/mednotes/skills/obsidian-markdown/references/PROPERTIES.md +61 -0
- package/.opencode/mednotes/skills/obsidian-ops/SKILL.md +136 -0
- package/.opencode/mednotes/skills/pdf-library/SKILL.md +45 -0
- package/.opencode/mednotes/skills/process-medical-chats/SKILL.md +246 -0
- package/.opencode/mednotes/skills/workflow-report/SKILL.md +100 -0
- package/.opencode/mednotes/src/mednotes/__init__.py +5 -0
- package/.opencode/mednotes/src/mednotes/domains/__init__.py +5 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/README.md +26 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/__init__.py +2 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/build_demo_apkg.py +177 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/contracts.py +385 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/flashcards_machine.py +522 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/fsm.py +817 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/index.py +630 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/install_models.py +445 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/model.py +359 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/obsidian_links.py +135 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/obsidian_note_utils.py +546 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/pipeline.py +580 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/report.py +510 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/sources.py +682 -0
- package/.opencode/mednotes/src/mednotes/domains/flashcards/sync_rules.py +184 -0
- package/.opencode/mednotes/src/mednotes/domains/history/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/history/history_fsm.py +852 -0
- package/.opencode/mednotes/src/mednotes/domains/history/history_machine.py +453 -0
- package/.opencode/mednotes/src/mednotes/domains/setup/__init__.py +7 -0
- package/.opencode/mednotes/src/mednotes/domains/setup/setup_fsm.py +808 -0
- package/.opencode/mednotes/src/mednotes/domains/setup/setup_machine.py +973 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/README.md +64 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/api.py +668 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/batch_state.py +102 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/atomicity/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/atomicity/atomicity.py +877 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/body_link/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/body_link/body_linker.py +1562 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/effects/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/effects/effect_adapters.py +949 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/effects/fix_wiki_runtime_adapters.py +433 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/coverage.py +413 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/graph.py +396 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/graph_fixes.py +161 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/hygiene/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/hygiene/hygiene.py +483 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/__init__.py +2 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/anchors.py +185 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/__init__.py +0 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/cache.py +223 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/config.py +131 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/download.py +224 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/frontmatter.py +59 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/insert.py +227 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/local_import.py +54 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/__init__.py +42 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/web_profiles.py +99 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/web_search.py +203 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/wikimedia.py +102 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/markdown_db_adapter.mjs +434 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/markdown_node_runtime.py +274 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/markdown_query.py +227 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/artifacts.py +605 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/canonical_merge.py +277 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/markdown_zones.py +85 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/meaning_planner.py +307 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_iter.py +67 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_merge.py +278 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_plan.py +409 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_policy.py +22 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/__init__.py +79 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/fixes.py +264 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/frontmatter.py +435 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/models.py +208 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/prompts.py +37 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/tables.py +236 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/validate.py +404 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/provenance.py +478 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/raw_chats.py +273 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/sources_backfill.py +235 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/__init__.py +10 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/anchors.py +16 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/captions.py +47 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/cli.py +179 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/cloud.py +52 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/config.py +196 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/context_packets.py +76 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/db.py +81 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/doctor.py +102 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/figure_ids.py +42 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/ingest.py +326 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/insert.py +316 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/mentions.py +57 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/ocr.py +71 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/paths.py +35 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/pdf_engine.py +77 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/schema.py +155 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/search.py +188 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/app.py +89 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/image_backend.py +29 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/state.py +65 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/publish.py +1139 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/publish_receipts.py +365 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/publish_recovery.py +240 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/agent_behavior_corpus.py +2069 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/agent_report_validation.py +4448 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/agent_run_audit.py +852 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/architect_prompt_eval.py +341 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/body_linker_eval.py +240 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/curator_output_validation.py +175 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/curator_prompt_eval.py +865 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/triager_prompt_eval.py +1295 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/related_notes/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/related_notes/related_notes.py +1920 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/related_notes/related_notes_headless.py +1186 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/plan_attestation.py +148 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/specialist_receipts.py +360 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/specialist_runtime.py +52 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/specialist_task_runner.py +2470 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/style/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/style/style.py +1952 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/subagents/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/subagents/agents.py +1767 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/alias_projection.py +331 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/link_terms.py +151 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/llm_disambiguation.py +182 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/__init__.py +116 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/audit.py +201 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/migration.py +314 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/normalize.py +72 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/policy.py +135 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/resolve.py +413 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/schema.py +157 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/status.py +137 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_bootstrap.py +509 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_curator_batch.py +1115 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_ingestion.py +632 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_map.py +930 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_recovery.py +1388 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/cli.py +6665 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/common.py +69 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/config.py +210 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/__init__.py +74 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/agent_report.py +242 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/agent_run_audit.py +196 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/agents.py +601 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/curator.py +256 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/effect_payloads.py +519 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/happy_path.py +190 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/link_git.py +110 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/link_runtime_artifact.py +52 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/note_plan.py +75 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/paths.py +114 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/public_report.py +53 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/publish.py +111 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/raw_coverage.py +217 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/related_notes.py +136 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/related_notes_headless.py +153 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/related_notes_runtime.py +395 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/schema_registry.py +637 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/specialist.py +432 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/status.py +62 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/style_rewrite.py +568 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/vocabulary_ingestion.py +223 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_blockers.py +510 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_guardrails.py +637 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_outcomes.py +121 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_receipts.py +100 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/__main__.py +4 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/cli.py +275 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/__init__.py +2 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/candidates.py +193 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/cli.py +189 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/gemini.py +220 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/inputs.py +120 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/models.py +34 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/parsing.py +48 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/prompts.py +216 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/quality.py +54 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/reporting.py +24 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/runner.py +433 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/utils.py +39 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/vault_guard_bridge.py +17 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_context_packets.py +454 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_decision_projection.py +133 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_effects.py +1260 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_fsm.py +2768 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_machine.py +1588 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_plan.py +306 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_primary_objective.py +316 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_problem.py +153 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_receipt_evidence.py +306 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_states.py +290 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_user_report.py +342 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/health.py +6332 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_fsm.py +1119 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_git.py +638 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_machine.py +1106 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_retry_governance.py +374 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_runtime_result.py +485 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_triggers.py +183 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/linking.py +2758 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/reference_repair.py +718 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/related_notes_fsm.py +1855 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link_related/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link_related/link_related_machine.py +834 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/__init__.py +1 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_fsm.py +1592 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_machine.py +3097 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_primary_objective.py +28 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_runtime_result.py +185 -0
- package/.opencode/mednotes/src/mednotes/domains/wiki/performance.py +97 -0
- package/.opencode/mednotes/src/mednotes/kernel/__init__.py +6 -0
- package/.opencode/mednotes/src/mednotes/kernel/agent_directive.py +336 -0
- package/.opencode/mednotes/src/mednotes/kernel/base.py +51 -0
- package/.opencode/mednotes/src/mednotes/kernel/blockers.py +39 -0
- package/.opencode/mednotes/src/mednotes/kernel/effect_executor.py +55 -0
- package/.opencode/mednotes/src/mednotes/kernel/effect_intent.py +69 -0
- package/.opencode/mednotes/src/mednotes/kernel/effects.py +160 -0
- package/.opencode/mednotes/src/mednotes/kernel/errors.py +38 -0
- package/.opencode/mednotes/src/mednotes/kernel/fsm_event.py +35 -0
- package/.opencode/mednotes/src/mednotes/kernel/fsm_model.py +55 -0
- package/.opencode/mednotes/src/mednotes/kernel/fsm_transition_result.py +75 -0
- package/.opencode/mednotes/src/mednotes/kernel/guardrails.py +188 -0
- package/.opencode/mednotes/src/mednotes/kernel/progress.py +319 -0
- package/.opencode/mednotes/src/mednotes/kernel/public_report.py +346 -0
- package/.opencode/mednotes/src/mednotes/kernel/state_machine.py +164 -0
- package/.opencode/mednotes/src/mednotes/kernel/workflow.py +619 -0
- package/.opencode/mednotes/src/mednotes/platform/__init__.py +5 -0
- package/.opencode/mednotes/src/mednotes/platform/backup_policy.py +382 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/__init__.py +62 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/cli.py +275 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/contracts.py +83 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/core.py +4168 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/integrity.py +989 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/operational_contract.py +2293 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/telemetry.py +875 -0
- package/.opencode/mednotes/src/mednotes/platform/feedback/telemetry_config.py +65 -0
- package/.opencode/mednotes/src/mednotes/platform/opencode_runtime_config.py +182 -0
- package/.opencode/mednotes/src/mednotes/platform/paths/__init__.py +1560 -0
- package/.opencode/mednotes/src/mednotes/platform/secrets.py +89 -0
- package/.opencode/mednotes/src/mednotes/platform/user_config.py +103 -0
- package/.opencode/mednotes/src/mednotes/platform/vault_guard.py +214 -0
- package/.opencode/mednotes/uv.lock +932 -0
- package/.opencode/mednotes.generated.json +395 -0
- package/.opencode/opencode.json +31 -0
- package/.opencode/plugins/mednotes-fsm.mjs +7 -0
- package/.opencode/plugins/mednotes_hook/adapters/antigravity.mjs +169 -0
- package/.opencode/plugins/mednotes_hook/adapters/harness_payload.mjs +103 -0
- package/.opencode/plugins/mednotes_hook/adapters/opencode_plugin.mjs +341 -0
- package/.opencode/plugins/mednotes_hook/adapters/opencode_user_config_sync.mjs +177 -0
- package/.opencode/plugins/mednotes_hook/anki_preflight.mjs +214 -0
- package/.opencode/plugins/mednotes_hook/cli.mjs +143 -0
- package/.opencode/plugins/mednotes_hook/diagnostics.mjs +11 -0
- package/.opencode/plugins/mednotes_hook/domain/agent_directive_core.mjs +160 -0
- package/.opencode/plugins/mednotes_hook/fsm_directive.mjs +1470 -0
- package/.opencode/plugins/mednotes_hook/hook_errors.mjs +120 -0
- package/.opencode/plugins/mednotes_hook/retention.mjs +114 -0
- package/.opencode/plugins/mednotes_hook/runtime.mjs +174 -0
- package/.opencode/plugins/mednotes_hook/telemetry_capture.mjs +511 -0
- package/.opencode/plugins/mednotes_hook/vault_guard.mjs +624 -0
- package/AGENTS.md +57 -0
- package/README.md +194 -0
- package/adapters/antigravity/agents.json +80 -0
- package/adapters/antigravity/templates/med-chat-triager.md +214 -0
- package/adapters/antigravity/templates/med-flashcard-maker.md +72 -0
- package/adapters/antigravity/templates/med-knowledge-architect.md +241 -0
- package/adapters/antigravity/templates/med-link-graph-curator.md +187 -0
- package/adapters/antigravity/templates/med-publish-guard.md +71 -0
- package/adapters/gemini-cli/gemini-extension.json +14 -0
- package/adapters/gemini-cli/package.json +15 -0
- package/adapters/gemini-cli/pyproject.toml +48 -0
- package/bin/mednotes-opencode.mjs +155 -0
- package/contracts/agents.json +116 -0
- package/core/agents/med-chat-triager.md +197 -0
- package/core/agents/med-flashcard-maker.md +56 -0
- package/core/agents/med-knowledge-architect.md +224 -0
- package/core/agents/med-link-graph-curator.md +171 -0
- package/core/agents/med-publish-guard.md +55 -0
- package/core/commands/flashcards.toml +22 -0
- package/core/commands/mednotes/create.toml +22 -0
- package/core/commands/mednotes/enrich.toml +24 -0
- package/core/commands/mednotes/fix-wiki.toml +24 -0
- package/core/commands/mednotes/history.toml +19 -0
- package/core/commands/mednotes/link-body.toml +22 -0
- package/core/commands/mednotes/link-related.toml +24 -0
- package/core/commands/mednotes/link.toml +24 -0
- package/core/commands/mednotes/pdf-library.toml +24 -0
- package/core/commands/mednotes/process-chats.toml +20 -0
- package/core/commands/mednotes/setup.toml +18 -0
- package/core/commands/mednotes/status.toml +24 -0
- package/core/commands/mednotes/telemetry.toml +24 -0
- package/core/commands/report.toml +23 -0
- package/core/skills/THIRD_PARTY_NOTICES.md +45 -0
- package/core/skills/create-medical-flashcards/SKILL.md +113 -0
- package/core/skills/create-medical-note/SKILL.md +90 -0
- package/core/skills/enrich-medical-note/SKILL.md +120 -0
- package/core/skills/fix-medical-wiki/SKILL.md +559 -0
- package/core/skills/link-medical-wiki/SKILL.md +224 -0
- package/core/skills/obsidian-cli/SKILL.md +118 -0
- package/core/skills/obsidian-markdown/SKILL.md +207 -0
- package/core/skills/obsidian-markdown/references/CALLOUTS.md +58 -0
- package/core/skills/obsidian-markdown/references/EMBEDS.md +63 -0
- package/core/skills/obsidian-markdown/references/PROPERTIES.md +61 -0
- package/core/skills/obsidian-ops/SKILL.md +136 -0
- package/core/skills/pdf-library/SKILL.md +45 -0
- package/core/skills/process-medical-chats/SKILL.md +246 -0
- package/core/skills/workflow-report/SKILL.md +100 -0
- package/package.json +45 -0
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Prepare and apply deterministic /flashcards write plans.
|
|
3
|
+
|
|
4
|
+
This script glues together the local contracts around the LLM-owned card
|
|
5
|
+
formulation step. It does not call Anki itself; it prepares the payload the
|
|
6
|
+
agent should send to Anki MCP and records/report accepted results afterwards.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
import sys
|
|
14
|
+
import time
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
from pydantic import ValidationError as PydanticValidationError
|
|
18
|
+
|
|
19
|
+
SCRIPT_DIR = Path(__file__).resolve().parent
|
|
20
|
+
# Direct script execution must import the local package, not an installed stale
|
|
21
|
+
# distribution. The package root for ``mednotes.domains...`` is ``bundle/src``.
|
|
22
|
+
PACKAGE_ROOT = SCRIPT_DIR.parents[2]
|
|
23
|
+
if str(PACKAGE_ROOT) not in sys.path:
|
|
24
|
+
sys.path.insert(0, str(PACKAGE_ROOT))
|
|
25
|
+
|
|
26
|
+
from mednotes.domains.flashcards import index as flashcard_index # noqa: E402
|
|
27
|
+
from mednotes.domains.flashcards import model as anki_model_validator # noqa: E402
|
|
28
|
+
from mednotes.domains.flashcards import report as flashcard_report # noqa: E402
|
|
29
|
+
from mednotes.domains.flashcards.contracts import ( # noqa: E402
|
|
30
|
+
FLASHCARD_APPLY_SCHEMA,
|
|
31
|
+
FlashcardAnkiNote,
|
|
32
|
+
FlashcardApplyResult,
|
|
33
|
+
FlashcardCandidateBatch,
|
|
34
|
+
FlashcardIndexCheck,
|
|
35
|
+
FlashcardIndexSummary,
|
|
36
|
+
FlashcardModelPreference,
|
|
37
|
+
FlashcardModelValidation,
|
|
38
|
+
FlashcardObsidianLinkError,
|
|
39
|
+
FlashcardPreparedCard,
|
|
40
|
+
FlashcardSourceStatus,
|
|
41
|
+
FlashcardWritePlan,
|
|
42
|
+
FlashcardWriteSummary,
|
|
43
|
+
normalize_candidate_batch,
|
|
44
|
+
)
|
|
45
|
+
from mednotes.domains.flashcards.flashcards_machine import ( # noqa: E402
|
|
46
|
+
AnkiWriteCompletedEvent,
|
|
47
|
+
CandidateGenerationCompletedEvent,
|
|
48
|
+
FlashcardsBlockedEvent,
|
|
49
|
+
FlashcardsFailedEvent,
|
|
50
|
+
FlashcardsMachine,
|
|
51
|
+
FlashcardsState,
|
|
52
|
+
NoCardsToCreateEvent,
|
|
53
|
+
SourcesResolvedEvent,
|
|
54
|
+
)
|
|
55
|
+
from mednotes.domains.flashcards.fsm import ( # noqa: E402
|
|
56
|
+
flashcards_fsm_payload_from_model,
|
|
57
|
+
)
|
|
58
|
+
from mednotes.kernel.base import JsonObject, JsonObjectAdapter # noqa: E402
|
|
59
|
+
from mednotes.kernel.fsm_model import WorkflowModel # noqa: E402
|
|
60
|
+
from mednotes.kernel.state_machine import send_workflow_event # noqa: E402
|
|
61
|
+
from mednotes.platform.feedback import command_string, safe_record_workflow_run # noqa: E402
|
|
62
|
+
|
|
63
|
+
PREPARE_SCHEMA = "medical-notes-workbench.flashcard-write-plan.v1"
|
|
64
|
+
APPLY_SCHEMA = FLASHCARD_APPLY_SCHEMA
|
|
65
|
+
EXIT_OK = 0
|
|
66
|
+
EXIT_BLOCKED = 3
|
|
67
|
+
EXIT_IO = 5
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _read_json(path: str) -> object:
|
|
71
|
+
if path == "-":
|
|
72
|
+
return json.loads(sys.stdin.read())
|
|
73
|
+
with Path(path).open("r", encoding="utf-8") as fh:
|
|
74
|
+
return json.load(fh)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _json(data: object) -> None:
|
|
78
|
+
print(json.dumps(data, ensure_ascii=False, indent=2, sort_keys=True))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _json_object(value: object) -> JsonObject:
|
|
82
|
+
return JsonObjectAdapter.validate_python(value) if isinstance(value, dict) else {}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _json_field(payload: JsonObject, key: str) -> object:
|
|
86
|
+
if key not in payload:
|
|
87
|
+
return None
|
|
88
|
+
return payload[key]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _json_str_field(payload: JsonObject, key: str) -> str:
|
|
92
|
+
value = _json_field(payload, key)
|
|
93
|
+
return value if isinstance(value, str) else ""
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _json_object_field(payload: JsonObject, key: str) -> JsonObject:
|
|
97
|
+
value = _json_field(payload, key)
|
|
98
|
+
return JsonObjectAdapter.validate_python(value) if isinstance(value, dict) else {}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _record_feedback(payload: JsonObject, exit_code: int, started_at: float) -> None:
|
|
102
|
+
safe_record_workflow_run(
|
|
103
|
+
workflow="/flashcards",
|
|
104
|
+
command=command_string(),
|
|
105
|
+
payload=payload,
|
|
106
|
+
exit_code=exit_code,
|
|
107
|
+
started_at=started_at,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _index_path(value: str | None = None) -> Path:
|
|
112
|
+
return Path(
|
|
113
|
+
os.path.expandvars(
|
|
114
|
+
value or os.getenv("MED_FLASHCARDS_INDEX") or flashcard_index.DEFAULT_INDEX
|
|
115
|
+
)
|
|
116
|
+
).expanduser()
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _models_payload(payload: JsonObject) -> object:
|
|
120
|
+
for key in ("models", "model_fields", "anki_models"):
|
|
121
|
+
value = _json_field(payload, key)
|
|
122
|
+
if value:
|
|
123
|
+
return value
|
|
124
|
+
return {}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _source_manifest(payload: JsonObject) -> JsonObject:
|
|
128
|
+
return _json_object_field(payload, "source_manifest")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _field(card: FlashcardPreparedCard, name: str) -> str:
|
|
132
|
+
match name:
|
|
133
|
+
case "Frente":
|
|
134
|
+
return card.fields.Frente
|
|
135
|
+
case "Verso":
|
|
136
|
+
return card.fields.Verso
|
|
137
|
+
case "Verso Extra":
|
|
138
|
+
return card.fields.Verso_Extra
|
|
139
|
+
case "Obsidian":
|
|
140
|
+
return card.fields.Obsidian
|
|
141
|
+
case "Texto":
|
|
142
|
+
return card.fields.Texto
|
|
143
|
+
return ""
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _anki_note_for(card: FlashcardPreparedCard, model_name: str) -> FlashcardAnkiNote:
|
|
147
|
+
return FlashcardAnkiNote(
|
|
148
|
+
deckName=card.deck,
|
|
149
|
+
modelName=card.note_model or model_name,
|
|
150
|
+
fields=card.fields,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def _find_query_for(card: FlashcardPreparedCard) -> str:
|
|
155
|
+
obsidian = _field(card, "Obsidian")
|
|
156
|
+
deck = card.deck
|
|
157
|
+
note_model = card.note_model
|
|
158
|
+
is_cloze = note_model == anki_model_validator.DEFAULT_CLOZE_MODEL or bool(
|
|
159
|
+
_field(card, "Texto")
|
|
160
|
+
)
|
|
161
|
+
parts = []
|
|
162
|
+
if deck:
|
|
163
|
+
parts.append(f'deck:"{deck}"')
|
|
164
|
+
if obsidian:
|
|
165
|
+
parts.append(f'Obsidian:"{obsidian}"')
|
|
166
|
+
if is_cloze:
|
|
167
|
+
text = _field(card, "Texto")
|
|
168
|
+
if text:
|
|
169
|
+
parts.append(f'Texto:"{text}"')
|
|
170
|
+
else:
|
|
171
|
+
front = _field(card, "Frente")
|
|
172
|
+
if front:
|
|
173
|
+
parts.append(f'Frente:"{front}"')
|
|
174
|
+
return " ".join(parts)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _payload_uses_model_set(payload: JsonObject, candidate_batch: FlashcardCandidateBatch) -> bool:
|
|
178
|
+
if _json_object_field(payload, "preferred_models"):
|
|
179
|
+
return True
|
|
180
|
+
return any(card.note_model == anki_model_validator.DEFAULT_CLOZE_MODEL for card in candidate_batch.candidate_cards)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def _model_preference(payload: JsonObject) -> FlashcardModelPreference:
|
|
184
|
+
preferred_models = _json_object_field(payload, "preferred_models")
|
|
185
|
+
return FlashcardModelPreference.model_validate(
|
|
186
|
+
{
|
|
187
|
+
"preferred_model": _json_field(payload, "preferred_model"),
|
|
188
|
+
"preferred_models": preferred_models,
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _candidate_batch_payload(payload: JsonObject) -> JsonObject:
|
|
194
|
+
return {
|
|
195
|
+
"source_manifest": _json_field(payload, "source_manifest"),
|
|
196
|
+
"candidate_cards": _json_field(payload, "candidate_cards"),
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def _invalid_obsidian_plan() -> FlashcardWritePlan:
|
|
201
|
+
return FlashcardWritePlan(
|
|
202
|
+
blocked=True,
|
|
203
|
+
blocked_reason="invalid_obsidian_deeplink",
|
|
204
|
+
next_action=(
|
|
205
|
+
"Regenerar o manifest de fontes/links Obsidian e preparar novamente "
|
|
206
|
+
"antes de criar cards no Anki."
|
|
207
|
+
),
|
|
208
|
+
model_validation=FlashcardModelValidation(ok=False, missing_fields=["Obsidian"]),
|
|
209
|
+
source_status=FlashcardSourceStatus(),
|
|
210
|
+
index_check=FlashcardIndexCheck(
|
|
211
|
+
summary=FlashcardIndexSummary(candidate_count=0, new_count=0, duplicate_count=0),
|
|
212
|
+
),
|
|
213
|
+
summary=FlashcardWriteSummary(
|
|
214
|
+
candidate_count=0,
|
|
215
|
+
new_count=0,
|
|
216
|
+
duplicate_count=0,
|
|
217
|
+
changed_source_count=0,
|
|
218
|
+
anki_note_count=0,
|
|
219
|
+
),
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def _invalid_candidate_batch_plan() -> FlashcardWritePlan:
|
|
224
|
+
return FlashcardWritePlan(
|
|
225
|
+
blocked=True,
|
|
226
|
+
blocked_reason="invalid_flashcard_candidate_batch",
|
|
227
|
+
next_action=(
|
|
228
|
+
"Regenerar a prévia de flashcards a partir do manifest de fontes atual "
|
|
229
|
+
"antes de criar cards no Anki."
|
|
230
|
+
),
|
|
231
|
+
model_validation=FlashcardModelValidation(ok=False),
|
|
232
|
+
source_status=FlashcardSourceStatus(),
|
|
233
|
+
index_check=FlashcardIndexCheck(
|
|
234
|
+
summary=FlashcardIndexSummary(candidate_count=0, new_count=0, duplicate_count=0),
|
|
235
|
+
),
|
|
236
|
+
summary=FlashcardWriteSummary(
|
|
237
|
+
candidate_count=0,
|
|
238
|
+
new_count=0,
|
|
239
|
+
duplicate_count=0,
|
|
240
|
+
changed_source_count=0,
|
|
241
|
+
anki_note_count=0,
|
|
242
|
+
),
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def prepare_write_plan(payload: JsonObject, index: JsonObject) -> FlashcardWritePlan:
|
|
247
|
+
try:
|
|
248
|
+
candidate_batch = FlashcardCandidateBatch.model_validate(_candidate_batch_payload(payload))
|
|
249
|
+
except PydanticValidationError:
|
|
250
|
+
return _invalid_candidate_batch_plan()
|
|
251
|
+
|
|
252
|
+
try:
|
|
253
|
+
candidate_batch = normalize_candidate_batch(candidate_batch)
|
|
254
|
+
except FlashcardObsidianLinkError:
|
|
255
|
+
return _invalid_obsidian_plan()
|
|
256
|
+
|
|
257
|
+
normalized_payload: JsonObject = {
|
|
258
|
+
**payload,
|
|
259
|
+
"source_manifest": candidate_batch.source_manifest.to_payload(),
|
|
260
|
+
"candidate_cards": [card.to_payload() for card in candidate_batch.candidate_cards],
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
use_model_set = _payload_uses_model_set(normalized_payload, candidate_batch)
|
|
264
|
+
model_preference = _model_preference(normalized_payload)
|
|
265
|
+
if use_model_set:
|
|
266
|
+
model_validation = FlashcardModelValidation.model_validate(
|
|
267
|
+
anki_model_validator.validate_model_set(
|
|
268
|
+
_models_payload(normalized_payload),
|
|
269
|
+
preferred_qa_model=model_preference.preferred_models.qa
|
|
270
|
+
or anki_model_validator.DEFAULT_QA_MODEL,
|
|
271
|
+
preferred_cloze_model=model_preference.preferred_models.cloze
|
|
272
|
+
or anki_model_validator.DEFAULT_CLOZE_MODEL,
|
|
273
|
+
)
|
|
274
|
+
)
|
|
275
|
+
default_model_name = model_validation.qa.model if model_validation.qa is not None else ""
|
|
276
|
+
else:
|
|
277
|
+
model_validation = FlashcardModelValidation.model_validate(
|
|
278
|
+
anki_model_validator.validate_models(
|
|
279
|
+
_models_payload(normalized_payload),
|
|
280
|
+
preferred_model=model_preference.preferred_model or None,
|
|
281
|
+
)
|
|
282
|
+
)
|
|
283
|
+
default_model_name = model_validation.model
|
|
284
|
+
source_status = FlashcardSourceStatus.model_validate(
|
|
285
|
+
flashcard_index.source_status(_source_manifest(normalized_payload), index)
|
|
286
|
+
)
|
|
287
|
+
index_check = FlashcardIndexCheck.model_validate(flashcard_index.check_candidates(normalized_payload, index))
|
|
288
|
+
new_cards = index_check.new_cards if model_validation.ok else []
|
|
289
|
+
model_name = default_model_name
|
|
290
|
+
|
|
291
|
+
changed_sources = [item for item in source_status.sources if item.status == "changed"]
|
|
292
|
+
anki_notes = [_anki_note_for(card, model_name) for card in new_cards]
|
|
293
|
+
find_queries = [
|
|
294
|
+
{"card_hash": card.card_hash, "query": _find_query_for(card)} for card in new_cards
|
|
295
|
+
]
|
|
296
|
+
|
|
297
|
+
plan_payload = {
|
|
298
|
+
"schema": PREPARE_SCHEMA,
|
|
299
|
+
"blocked": not model_validation.ok,
|
|
300
|
+
"blocked_reason": "anki_model_validation_failed" if not model_validation.ok else "",
|
|
301
|
+
"next_action": (
|
|
302
|
+
"Corrigir/provisionar modelos Anki e preparar novamente."
|
|
303
|
+
if not model_validation.ok
|
|
304
|
+
else ""
|
|
305
|
+
),
|
|
306
|
+
"requires_reprocess_confirmation": bool(changed_sources),
|
|
307
|
+
"model_validation": model_validation,
|
|
308
|
+
"source_status": source_status,
|
|
309
|
+
"index_check": index_check,
|
|
310
|
+
"changed_sources": changed_sources,
|
|
311
|
+
"anki_find_queries": find_queries,
|
|
312
|
+
"anki_notes": anki_notes,
|
|
313
|
+
"new_cards": new_cards,
|
|
314
|
+
"duplicate_cards": index_check.duplicate_cards,
|
|
315
|
+
"summary": {
|
|
316
|
+
"candidate_count": index_check.summary.candidate_count,
|
|
317
|
+
"new_count": index_check.summary.new_count if model_validation.ok else 0,
|
|
318
|
+
"duplicate_count": index_check.summary.duplicate_count,
|
|
319
|
+
"changed_source_count": len(changed_sources),
|
|
320
|
+
"anki_note_count": len(anki_notes),
|
|
321
|
+
},
|
|
322
|
+
}
|
|
323
|
+
return FlashcardWritePlan.model_validate(plan_payload)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def apply_accepted(payload: JsonObject, index: JsonObject) -> tuple[JsonObject, JsonObject]:
|
|
327
|
+
updated, record_summary = flashcard_index.record_cards(payload, index)
|
|
328
|
+
apply_result = FlashcardApplyResult(
|
|
329
|
+
summary=JsonObjectAdapter.validate_python(record_summary),
|
|
330
|
+
report=flashcard_report.build_report_model(payload),
|
|
331
|
+
)
|
|
332
|
+
return JsonObjectAdapter.validate_python(updated), apply_result.to_payload()
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def _apply_fsm_payload_from_result(
|
|
336
|
+
result: JsonObject,
|
|
337
|
+
*,
|
|
338
|
+
run_id: str,
|
|
339
|
+
index_path: Path,
|
|
340
|
+
dry_run: bool,
|
|
341
|
+
) -> JsonObject:
|
|
342
|
+
"""Project Anki success without fabricating Obsidian tag completion.
|
|
343
|
+
|
|
344
|
+
The next executable step is the machine-owned `flashcards.tag_obsidian`
|
|
345
|
+
effect. Only the adapter receipt for that effect may later emit
|
|
346
|
+
`ObsidianTaggingCompletedEvent`.
|
|
347
|
+
"""
|
|
348
|
+
|
|
349
|
+
apply_result = FlashcardApplyResult.model_validate(result)
|
|
350
|
+
created_card_count = apply_result.report.summary.created_card_count
|
|
351
|
+
model = WorkflowModel.start(
|
|
352
|
+
workflow="/flashcards",
|
|
353
|
+
run_id=run_id,
|
|
354
|
+
initial_state=FlashcardsState.WRITING_ANKI.value,
|
|
355
|
+
)
|
|
356
|
+
machine = FlashcardsMachine(model=model, state_field=WorkflowModel.STATECHART_STATE_FIELD)
|
|
357
|
+
send_workflow_event(
|
|
358
|
+
machine,
|
|
359
|
+
AnkiWriteCompletedEvent(
|
|
360
|
+
workflow="/flashcards",
|
|
361
|
+
run_id=run_id,
|
|
362
|
+
current_state=FlashcardsState.WRITING_ANKI.value,
|
|
363
|
+
created_card_count=created_card_count,
|
|
364
|
+
),
|
|
365
|
+
)
|
|
366
|
+
fsm_payload = flashcards_fsm_payload_from_model(model)
|
|
367
|
+
artifacts = _json_object_field(fsm_payload, "artifacts")
|
|
368
|
+
return {
|
|
369
|
+
**fsm_payload,
|
|
370
|
+
"artifacts": {
|
|
371
|
+
**artifacts,
|
|
372
|
+
"apply_result": apply_result.to_payload(),
|
|
373
|
+
"index_path": str(index_path),
|
|
374
|
+
"dry_run": dry_run,
|
|
375
|
+
},
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def _failed_fsm_payload_for_command(command: str, exc: Exception, *, run_id: str) -> JsonObject:
|
|
380
|
+
"""Convert CLI exceptions into the `/flashcards` FSM contract on stdout."""
|
|
381
|
+
|
|
382
|
+
initial_state = FlashcardsState.WRITING_ANKI if command == "apply" else FlashcardsState.CHECKING_SOURCES
|
|
383
|
+
model = WorkflowModel.start(
|
|
384
|
+
workflow="/flashcards",
|
|
385
|
+
run_id=run_id,
|
|
386
|
+
initial_state=initial_state.value,
|
|
387
|
+
)
|
|
388
|
+
send_workflow_event(
|
|
389
|
+
FlashcardsMachine(model=model, state_field=WorkflowModel.STATECHART_STATE_FIELD),
|
|
390
|
+
FlashcardsFailedEvent(
|
|
391
|
+
workflow="/flashcards",
|
|
392
|
+
run_id=run_id,
|
|
393
|
+
current_state=initial_state.value,
|
|
394
|
+
reason_code="flashcards_apply_failed" if command == "apply" else "flashcards_prepare_failed",
|
|
395
|
+
next_action="Corrigir o input/indice local e rodar /flashcards novamente.",
|
|
396
|
+
audit_evidence={
|
|
397
|
+
"exception_type": exc.__class__.__name__,
|
|
398
|
+
"error_summary": str(exc),
|
|
399
|
+
},
|
|
400
|
+
),
|
|
401
|
+
)
|
|
402
|
+
return flashcards_fsm_payload_from_model(model)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
def _prepare_fsm_payload_from_plan(plan: FlashcardWritePlan, *, run_id: str) -> JsonObject:
|
|
406
|
+
"""Use FlashcardsMachine for operational states; keep facts path only for no-op completion."""
|
|
407
|
+
|
|
408
|
+
if plan.blocked:
|
|
409
|
+
model = WorkflowModel.start(
|
|
410
|
+
workflow="/flashcards",
|
|
411
|
+
run_id=run_id,
|
|
412
|
+
initial_state=FlashcardsState.CHECKING_SOURCES.value,
|
|
413
|
+
)
|
|
414
|
+
send_workflow_event(
|
|
415
|
+
FlashcardsMachine(model=model, state_field=WorkflowModel.STATECHART_STATE_FIELD),
|
|
416
|
+
FlashcardsBlockedEvent(
|
|
417
|
+
workflow="/flashcards",
|
|
418
|
+
run_id=run_id,
|
|
419
|
+
current_state=FlashcardsState.CHECKING_SOURCES.value,
|
|
420
|
+
reason_code=plan.blocked_reason or "flashcards_prepare_blocked",
|
|
421
|
+
next_action=plan.next_action or "Corrigir o bloqueio indicado e preparar novamente.",
|
|
422
|
+
),
|
|
423
|
+
)
|
|
424
|
+
return flashcards_fsm_payload_from_model(model)
|
|
425
|
+
|
|
426
|
+
if plan.summary.new_count > 0:
|
|
427
|
+
model = WorkflowModel.start(
|
|
428
|
+
workflow="/flashcards",
|
|
429
|
+
run_id=run_id,
|
|
430
|
+
initial_state=FlashcardsState.CHECKING_SOURCES.value,
|
|
431
|
+
)
|
|
432
|
+
machine = FlashcardsMachine(model=model, state_field=WorkflowModel.STATECHART_STATE_FIELD)
|
|
433
|
+
send_workflow_event(
|
|
434
|
+
machine,
|
|
435
|
+
SourcesResolvedEvent(
|
|
436
|
+
workflow="/flashcards",
|
|
437
|
+
run_id=run_id,
|
|
438
|
+
current_state=FlashcardsState.CHECKING_SOURCES.value,
|
|
439
|
+
source_count=len(plan.source_status.sources),
|
|
440
|
+
),
|
|
441
|
+
)
|
|
442
|
+
send_workflow_event(
|
|
443
|
+
machine,
|
|
444
|
+
CandidateGenerationCompletedEvent(
|
|
445
|
+
workflow="/flashcards",
|
|
446
|
+
run_id=run_id,
|
|
447
|
+
current_state=FlashcardsState.WAITING_AGENT_CANDIDATES.value,
|
|
448
|
+
candidate_count=plan.summary.candidate_count,
|
|
449
|
+
new_card_count=plan.summary.new_count,
|
|
450
|
+
),
|
|
451
|
+
)
|
|
452
|
+
return flashcards_fsm_payload_from_model(model)
|
|
453
|
+
|
|
454
|
+
model = WorkflowModel.start(
|
|
455
|
+
workflow="/flashcards",
|
|
456
|
+
run_id=run_id,
|
|
457
|
+
initial_state=FlashcardsState.CHECKING_SOURCES.value,
|
|
458
|
+
)
|
|
459
|
+
machine = FlashcardsMachine(model=model, state_field=WorkflowModel.STATECHART_STATE_FIELD)
|
|
460
|
+
send_workflow_event(
|
|
461
|
+
machine,
|
|
462
|
+
SourcesResolvedEvent(
|
|
463
|
+
workflow="/flashcards",
|
|
464
|
+
run_id=run_id,
|
|
465
|
+
current_state=FlashcardsState.CHECKING_SOURCES.value,
|
|
466
|
+
source_count=len(plan.source_status.sources),
|
|
467
|
+
),
|
|
468
|
+
)
|
|
469
|
+
send_workflow_event(
|
|
470
|
+
machine,
|
|
471
|
+
NoCardsToCreateEvent(
|
|
472
|
+
workflow="/flashcards",
|
|
473
|
+
run_id=run_id,
|
|
474
|
+
current_state=FlashcardsState.WAITING_AGENT_CANDIDATES.value,
|
|
475
|
+
source_count=len(plan.source_status.sources),
|
|
476
|
+
candidate_count=plan.summary.candidate_count,
|
|
477
|
+
duplicate_card_count=plan.summary.duplicate_count,
|
|
478
|
+
),
|
|
479
|
+
)
|
|
480
|
+
return flashcards_fsm_payload_from_model(model)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
def _cmd_prepare(args: argparse.Namespace) -> int:
|
|
484
|
+
started_at = time.time()
|
|
485
|
+
payload = _json_object(_read_json(args.input))
|
|
486
|
+
path = _index_path(args.index)
|
|
487
|
+
plan = prepare_write_plan(payload, JsonObjectAdapter.validate_python(flashcard_index._load_index(path)))
|
|
488
|
+
fsm_payload = _prepare_fsm_payload_from_plan(plan, run_id=f"flashcards-{int(started_at)}")
|
|
489
|
+
diagnostic_context = _json_object_field(fsm_payload, "diagnostic_context")
|
|
490
|
+
artifacts = _json_object_field(fsm_payload, "artifacts")
|
|
491
|
+
public_payload = {
|
|
492
|
+
**fsm_payload,
|
|
493
|
+
"artifacts": {
|
|
494
|
+
**artifacts,
|
|
495
|
+
"write_plan": plan.to_payload(),
|
|
496
|
+
"index_path": str(path),
|
|
497
|
+
},
|
|
498
|
+
}
|
|
499
|
+
if diagnostic_context:
|
|
500
|
+
public_payload["diagnostic_context"] = diagnostic_context
|
|
501
|
+
_json(public_payload)
|
|
502
|
+
progress = _json_object_field(public_payload, "progress_view_model")
|
|
503
|
+
progress_status = _json_str_field(progress, "status")
|
|
504
|
+
exit_code = EXIT_BLOCKED if progress_status == "blocked" else EXIT_OK
|
|
505
|
+
_record_feedback(public_payload, exit_code, started_at)
|
|
506
|
+
return exit_code
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
def _cmd_apply(args: argparse.Namespace) -> int:
|
|
510
|
+
started_at = time.time()
|
|
511
|
+
payload = _json_object(_read_json(args.input))
|
|
512
|
+
path = _index_path(args.index)
|
|
513
|
+
updated, result = apply_accepted(payload, JsonObjectAdapter.validate_python(flashcard_index._load_index(path)))
|
|
514
|
+
if not args.dry_run:
|
|
515
|
+
flashcard_index._write_json_atomic(path, updated)
|
|
516
|
+
fsm_payload = _apply_fsm_payload_from_result(
|
|
517
|
+
result,
|
|
518
|
+
run_id=f"flashcards-{int(started_at)}",
|
|
519
|
+
index_path=path,
|
|
520
|
+
dry_run=args.dry_run,
|
|
521
|
+
)
|
|
522
|
+
_json(fsm_payload)
|
|
523
|
+
_record_feedback(
|
|
524
|
+
fsm_payload,
|
|
525
|
+
EXIT_OK,
|
|
526
|
+
started_at,
|
|
527
|
+
)
|
|
528
|
+
return EXIT_OK
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
532
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
533
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
534
|
+
|
|
535
|
+
prepare = sub.add_parser("prepare", help="prepare an Anki write plan from candidate cards")
|
|
536
|
+
prepare.add_argument("--input", required=True, help="candidate run JSON, or '-' for stdin")
|
|
537
|
+
prepare.add_argument("--index", help=f"index path; default {flashcard_index.DEFAULT_INDEX}")
|
|
538
|
+
prepare.set_defaults(func=_cmd_prepare)
|
|
539
|
+
|
|
540
|
+
apply = sub.add_parser("apply", help="record accepted Anki cards and emit final report")
|
|
541
|
+
apply.add_argument("--input", required=True, help="accepted run JSON, or '-' for stdin")
|
|
542
|
+
apply.add_argument("--index", help=f"index path; default {flashcard_index.DEFAULT_INDEX}")
|
|
543
|
+
apply.add_argument("--dry-run", action="store_true", help="report without writing index")
|
|
544
|
+
apply.set_defaults(func=_cmd_apply)
|
|
545
|
+
|
|
546
|
+
return parser
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
def main(argv: list[str] | None = None) -> int:
|
|
550
|
+
parser = build_parser()
|
|
551
|
+
args = parser.parse_args(argv)
|
|
552
|
+
try:
|
|
553
|
+
return args.func(args)
|
|
554
|
+
except (
|
|
555
|
+
OSError,
|
|
556
|
+
json.JSONDecodeError,
|
|
557
|
+
flashcard_index.IndexErrorWithCode,
|
|
558
|
+
flashcard_report.FlashcardReportInputError,
|
|
559
|
+
) as exc:
|
|
560
|
+
exit_code = getattr(exc, "exit_code", EXIT_IO)
|
|
561
|
+
fsm_payload = _failed_fsm_payload_for_command(
|
|
562
|
+
str(getattr(args, "command", "unknown")),
|
|
563
|
+
exc,
|
|
564
|
+
run_id=f"flashcards-{int(time.time())}",
|
|
565
|
+
)
|
|
566
|
+
_json(fsm_payload)
|
|
567
|
+
safe_record_workflow_run(
|
|
568
|
+
workflow="/flashcards",
|
|
569
|
+
command=command_string(),
|
|
570
|
+
payload=fsm_payload,
|
|
571
|
+
exit_code=exit_code,
|
|
572
|
+
started_at=time.time(),
|
|
573
|
+
snippets=[str(exc)],
|
|
574
|
+
)
|
|
575
|
+
print(str(exc), file=sys.stderr)
|
|
576
|
+
return exit_code
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
if __name__ == "__main__":
|
|
580
|
+
raise SystemExit(main())
|