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
package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/validate.py
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"""Validation entrypoints for the Wiki_Medicina note style contract."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from mednotes.domains.wiki.capabilities.notes.markdown_zones import blank_protected_markdown, protected_markdown_zones
|
|
9
|
+
from mednotes.domains.wiki.capabilities.notes.note_iter import iter_notes
|
|
10
|
+
from mednotes.domains.wiki.capabilities.notes.note_policy import is_operational_index_note
|
|
11
|
+
from mednotes.domains.wiki.capabilities.notes.note_style.frontmatter import (
|
|
12
|
+
FrontmatterYamlUnavailable,
|
|
13
|
+
infer_title,
|
|
14
|
+
normalize_wiki_frontmatter,
|
|
15
|
+
split_frontmatter,
|
|
16
|
+
)
|
|
17
|
+
from mednotes.domains.wiki.capabilities.notes.note_style.models import (
|
|
18
|
+
PREFERRED_H2_EMOJIS,
|
|
19
|
+
REQUIRED_SECTION_LINES,
|
|
20
|
+
REWRITE_REQUIRED_CODES,
|
|
21
|
+
REWRITE_TRIGGER_WARNING_CODES,
|
|
22
|
+
STYLE_AUDIT_SCHEMA,
|
|
23
|
+
STYLE_REPORT_SCHEMA,
|
|
24
|
+
WIKI_INDEX_LINK,
|
|
25
|
+
StyleIssue,
|
|
26
|
+
)
|
|
27
|
+
from mednotes.domains.wiki.capabilities.notes.note_style.prompts import rewrite_prompt
|
|
28
|
+
from mednotes.domains.wiki.capabilities.notes.note_style.tables import check_tables
|
|
29
|
+
from mednotes.domains.wiki.capabilities.notes.provenance import audit_note_provenance
|
|
30
|
+
from mednotes.domains.wiki.performance import cooperative_cpu_yield
|
|
31
|
+
|
|
32
|
+
_HEADING_EMOJI_RE = re.compile(r"^[\U0001F300-\U0001FAFF\u2600-\u27BF]")
|
|
33
|
+
_LOCAL_PATH_RE = re.compile(r"(?:[A-Za-z]:\\|/Users/|/home/|/var/|/tmp/)")
|
|
34
|
+
_MALFORMED_ALIAS_RE = re.compile(r"\[\[([^\]\|]+)\]\]([A-ZÁÉÍÓÚÇ]{2,12})\b")
|
|
35
|
+
_CALLOUT_START_RE = re.compile(r"^>\s*\[![A-Za-z]+]")
|
|
36
|
+
_CLINICAL_VISUAL_H2_EMOJIS = {"🧠", "🔎", "🩺", "⚖️"}
|
|
37
|
+
_MERMAID_KEYWORD_RE = re.compile(
|
|
38
|
+
r"\b(?:algoritmo|cadeia\s+causal|classifica(?:cao|ção)|decis(?:ao|ão)|estratifica(?:cao|ção)|"
|
|
39
|
+
r"etapas?|fluxo|sequ(?:e|ê)ncia|via)\b",
|
|
40
|
+
re.IGNORECASE,
|
|
41
|
+
)
|
|
42
|
+
_CAUSAL_CONNECTOR_RE = re.compile(
|
|
43
|
+
r"\b(?:causa|causam|emboliza|embolizar|evolui|gera|geram|gerar|leva|levam|progride|resulta)\b",
|
|
44
|
+
re.IGNORECASE,
|
|
45
|
+
)
|
|
46
|
+
_EQUATION_KEYWORD_RE = re.compile(
|
|
47
|
+
r"\b(?:calcular|calculo|cálculo|equacao|equação|formula|fórmula|pontuacao|pontuação|"
|
|
48
|
+
r"razao|razão|relacao\s+entre|relação\s+entre)\b",
|
|
49
|
+
re.IGNORECASE,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def validate_note_style(
|
|
54
|
+
content: str,
|
|
55
|
+
*,
|
|
56
|
+
title: str,
|
|
57
|
+
raw_meta: dict[str, str] | None = None,
|
|
58
|
+
path: str | None = None,
|
|
59
|
+
fixes_applied: list[str] | None = None,
|
|
60
|
+
) -> dict[str, Any]:
|
|
61
|
+
if _is_operational_index_note(content, title=title, path=path):
|
|
62
|
+
return index_style_report(content, title=title, path=path, fixes_applied=fixes_applied)
|
|
63
|
+
frontmatter, body = split_frontmatter(content)
|
|
64
|
+
errors: list[StyleIssue] = []
|
|
65
|
+
warnings: list[StyleIssue] = []
|
|
66
|
+
|
|
67
|
+
_check_frontmatter(content, title, errors)
|
|
68
|
+
_check_title_and_definition(body, title, errors, warnings)
|
|
69
|
+
_check_headings(body, errors, warnings)
|
|
70
|
+
_check_required_sections(body, errors)
|
|
71
|
+
_check_footer(content, body, errors, warnings)
|
|
72
|
+
check_tables(body, errors)
|
|
73
|
+
_check_style_warnings(body, warnings)
|
|
74
|
+
_check_didactic_visual_opportunities(body, warnings)
|
|
75
|
+
|
|
76
|
+
error_payload = [issue.to_json() for issue in errors]
|
|
77
|
+
warning_payload = [issue.to_json() for issue in warnings]
|
|
78
|
+
requires_llm_rewrite = any(issue.code in REWRITE_REQUIRED_CODES for issue in errors) or any(
|
|
79
|
+
issue.code in REWRITE_TRIGGER_WARNING_CODES for issue in warnings
|
|
80
|
+
)
|
|
81
|
+
return {
|
|
82
|
+
"schema": STYLE_REPORT_SCHEMA,
|
|
83
|
+
"path": path,
|
|
84
|
+
"title": title,
|
|
85
|
+
"ok": not errors,
|
|
86
|
+
"errors": error_payload,
|
|
87
|
+
"warnings": warning_payload,
|
|
88
|
+
"fixes_applied": fixes_applied or [],
|
|
89
|
+
"requires_llm_rewrite": requires_llm_rewrite,
|
|
90
|
+
"rewrite_prompt": rewrite_prompt(title, error_payload, warning_payload) if requires_llm_rewrite else None,
|
|
91
|
+
"frontmatter_present": frontmatter is not None,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def validate_wiki_dir(wiki_dir: Path) -> dict[str, Any]:
|
|
96
|
+
files = iter_notes(wiki_dir)
|
|
97
|
+
reports = []
|
|
98
|
+
for index, path in enumerate(files, start=1):
|
|
99
|
+
cooperative_cpu_yield(index)
|
|
100
|
+
content = path.read_text(encoding="utf-8")
|
|
101
|
+
title = infer_title(content, path)
|
|
102
|
+
if is_operational_index_note(path, content):
|
|
103
|
+
reports.append(index_style_report(content, title=title, path=str(path)))
|
|
104
|
+
continue
|
|
105
|
+
reports.append(validate_note_style(content, title=title, path=str(path)))
|
|
106
|
+
return {
|
|
107
|
+
"schema": STYLE_AUDIT_SCHEMA,
|
|
108
|
+
"wiki_dir": str(wiki_dir),
|
|
109
|
+
"file_count": len(files),
|
|
110
|
+
"ok_count": sum(1 for item in reports if item["ok"]),
|
|
111
|
+
"error_count": sum(1 for item in reports if item["errors"]),
|
|
112
|
+
"warning_count": sum(1 for item in reports if item["warnings"]),
|
|
113
|
+
"reports": reports,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _is_operational_index_note(content: str, *, title: str, path: str | None = None) -> bool:
|
|
118
|
+
note_path = Path(path) if path else Path(f"{title}.md")
|
|
119
|
+
return is_operational_index_note(note_path, content)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def index_style_report(
|
|
123
|
+
content: str,
|
|
124
|
+
*,
|
|
125
|
+
title: str,
|
|
126
|
+
path: str | None = None,
|
|
127
|
+
fixes_applied: list[str] | None = None,
|
|
128
|
+
) -> dict[str, Any]:
|
|
129
|
+
frontmatter, _body = split_frontmatter(content)
|
|
130
|
+
return {
|
|
131
|
+
"schema": STYLE_REPORT_SCHEMA,
|
|
132
|
+
"path": path,
|
|
133
|
+
"title": title,
|
|
134
|
+
"ok": True,
|
|
135
|
+
"errors": [],
|
|
136
|
+
"warnings": [],
|
|
137
|
+
"fixes_applied": fixes_applied or [],
|
|
138
|
+
"requires_llm_rewrite": False,
|
|
139
|
+
"rewrite_prompt": None,
|
|
140
|
+
"frontmatter_present": frontmatter is not None,
|
|
141
|
+
"skipped": True,
|
|
142
|
+
"skip_reason": "wiki_index",
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _check_title_and_definition(
|
|
147
|
+
body: str,
|
|
148
|
+
title: str,
|
|
149
|
+
errors: list[StyleIssue],
|
|
150
|
+
warnings: list[StyleIssue],
|
|
151
|
+
) -> None:
|
|
152
|
+
title_pattern = re.compile(rf"(?m)^#\s+{re.escape(title)}\s*$")
|
|
153
|
+
title_match = title_pattern.search(body)
|
|
154
|
+
if not title_match:
|
|
155
|
+
errors.append(StyleIssue("missing_title_heading", f"use a level-1 heading exactly as '# {title}'", "error"))
|
|
156
|
+
return
|
|
157
|
+
|
|
158
|
+
after_title = body[title_match.end() :]
|
|
159
|
+
before_first_h2 = re.split(r"(?m)^##\s+", after_title, maxsplit=1)[0]
|
|
160
|
+
definition_lines = [
|
|
161
|
+
line.strip()
|
|
162
|
+
for line in before_first_h2.splitlines()
|
|
163
|
+
if line.strip() and not line.lstrip().startswith((">", "-", "|"))
|
|
164
|
+
]
|
|
165
|
+
if not definition_lines:
|
|
166
|
+
warnings.append(StyleIssue("missing_definition", "add a short 2-4 line definition after the title", "warning"))
|
|
167
|
+
elif len(definition_lines) > 4:
|
|
168
|
+
warnings.append(StyleIssue("long_definition", "keep the opening definition to 2-4 lines", "warning"))
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _check_headings(body: str, errors: list[StyleIssue], warnings: list[StyleIssue]) -> None:
|
|
172
|
+
h2_matches = list(re.finditer(r"(?m)^##\s+(.+?)\s*$", body))
|
|
173
|
+
if not h2_matches:
|
|
174
|
+
errors.append(StyleIssue("missing_h2_sections", "include level-2 sections with emoji-prefixed headings", "error"))
|
|
175
|
+
return
|
|
176
|
+
|
|
177
|
+
for match in h2_matches:
|
|
178
|
+
heading = match.group(1).strip()
|
|
179
|
+
line = body.count("\n", 0, match.start()) + 1
|
|
180
|
+
if not _HEADING_EMOJI_RE.match(heading):
|
|
181
|
+
errors.append(
|
|
182
|
+
StyleIssue(
|
|
183
|
+
"h2_missing_emoji",
|
|
184
|
+
f"prefix this level-2 heading with a semantic emoji: ## {heading}",
|
|
185
|
+
"error",
|
|
186
|
+
line=line,
|
|
187
|
+
)
|
|
188
|
+
)
|
|
189
|
+
continue
|
|
190
|
+
emoji = heading.split(maxsplit=1)[0]
|
|
191
|
+
if emoji not in PREFERRED_H2_EMOJIS:
|
|
192
|
+
warnings.append(
|
|
193
|
+
StyleIssue(
|
|
194
|
+
"non_preferred_h2_emoji",
|
|
195
|
+
f"prefer the fixed semantic emoji set for this heading: ## {heading}",
|
|
196
|
+
"warning",
|
|
197
|
+
line=line,
|
|
198
|
+
)
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _check_required_sections(body: str, errors: list[StyleIssue]) -> None:
|
|
203
|
+
for line in REQUIRED_SECTION_LINES:
|
|
204
|
+
if not re.search(rf"(?m)^{re.escape(line)}\s*$", body):
|
|
205
|
+
errors.append(StyleIssue("missing_required_section", f"include the required section line '{line}'", "error"))
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _check_footer(content: str, body: str, errors: list[StyleIssue], warnings: list[StyleIssue]) -> None:
|
|
209
|
+
nonempty_lines = [line.strip() for line in body.splitlines() if line.strip()]
|
|
210
|
+
tail = nonempty_lines[-6:]
|
|
211
|
+
if any(line.startswith("obsidian://") or _LOCAL_PATH_RE.search(line) for line in tail):
|
|
212
|
+
errors.append(
|
|
213
|
+
StyleIssue(
|
|
214
|
+
"invalid_footer_link",
|
|
215
|
+
"do not use obsidian deeplinks or local absolute paths in the final footer",
|
|
216
|
+
"error",
|
|
217
|
+
)
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
if any(line == WIKI_INDEX_LINK or "_Índice_Medicina" in line or "Indice_Medicina" in line for line in tail):
|
|
221
|
+
errors.append(
|
|
222
|
+
StyleIssue(
|
|
223
|
+
"legacy_index_footer_link",
|
|
224
|
+
"do not end notes with an index backlink; only _Índice_Medicina should link to notes",
|
|
225
|
+
"error",
|
|
226
|
+
)
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
provenance = audit_note_provenance(content, chat_lookup=None)
|
|
230
|
+
provenance_errors = provenance.get("errors")
|
|
231
|
+
for issue in provenance_errors if isinstance(provenance_errors, list) else []:
|
|
232
|
+
if isinstance(issue, dict):
|
|
233
|
+
_append_provenance_error(str(issue.get("code", "")), str(issue.get("message", "")), errors)
|
|
234
|
+
provenance_warnings = provenance.get("warnings")
|
|
235
|
+
for issue in provenance_warnings if isinstance(provenance_warnings, list) else []:
|
|
236
|
+
if isinstance(issue, dict):
|
|
237
|
+
_append_provenance_warning(str(issue.get("code", "")), str(issue.get("message", "")), warnings)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def _append_provenance_error(code: str, message: str, errors: list[StyleIssue]) -> None:
|
|
241
|
+
if code == "provenance.legacy_chat_original_footer":
|
|
242
|
+
errors.append(StyleIssue("provenance.legacy_chat_original_footer", message, "error"))
|
|
243
|
+
elif code == "chats.shape_invalid":
|
|
244
|
+
errors.append(StyleIssue("chats.shape_invalid", message, "error"))
|
|
245
|
+
elif code == "provenance.sources_section_missing":
|
|
246
|
+
errors.append(StyleIssue("provenance.sources_section_missing", message, "error"))
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def _append_provenance_warning(code: str, message: str, warnings: list[StyleIssue]) -> None:
|
|
250
|
+
if code == "chats.missing_unrecoverable":
|
|
251
|
+
warnings.append(StyleIssue("chats.missing_unrecoverable", message, "warning"))
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _check_frontmatter(content: str, title: str, errors: list[StyleIssue]) -> None:
|
|
255
|
+
frontmatter, _body = split_frontmatter(content)
|
|
256
|
+
if frontmatter is None:
|
|
257
|
+
return
|
|
258
|
+
try:
|
|
259
|
+
normalized, _fixes = normalize_wiki_frontmatter(content, title=title, preserve_keys={"chats"})
|
|
260
|
+
except FrontmatterYamlUnavailable as exc:
|
|
261
|
+
errors.append(
|
|
262
|
+
StyleIssue(
|
|
263
|
+
"frontmatter_yaml_unavailable",
|
|
264
|
+
exc.next_action,
|
|
265
|
+
"error",
|
|
266
|
+
)
|
|
267
|
+
)
|
|
268
|
+
return
|
|
269
|
+
if normalized != content:
|
|
270
|
+
errors.append(
|
|
271
|
+
StyleIssue(
|
|
272
|
+
"frontmatter_not_canonical",
|
|
273
|
+
"use canonical Wiki YAML: omit it when empty; otherwise keep only multiline aliases, tags, and workflow metadata",
|
|
274
|
+
"error",
|
|
275
|
+
)
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def _check_style_warnings(body: str, warnings: list[StyleIssue]) -> None:
|
|
280
|
+
if re.search(r"\n{3,}## 🔗 Notas Relacionadas", body):
|
|
281
|
+
warnings.append(
|
|
282
|
+
StyleIssue(
|
|
283
|
+
"extra_blank_lines_before_related",
|
|
284
|
+
"use a single blank line before '## 🔗 Notas Relacionadas'",
|
|
285
|
+
"warning",
|
|
286
|
+
)
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
callout_count = len(re.findall(r"(?m)^>\s*\[!", body))
|
|
290
|
+
if callout_count > 2:
|
|
291
|
+
warnings.append(
|
|
292
|
+
StyleIssue("excessive_callouts", "use callouts rarely; keep only the strongest 1-2 per note", "warning")
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
lines = body.splitlines()
|
|
296
|
+
for idx, line in enumerate(lines):
|
|
297
|
+
if not _CALLOUT_START_RE.match(line.strip()):
|
|
298
|
+
continue
|
|
299
|
+
previous = lines[idx - 1].strip() if idx > 0 else ""
|
|
300
|
+
if previous:
|
|
301
|
+
warnings.append(
|
|
302
|
+
StyleIssue(
|
|
303
|
+
"missing_blank_line_before_callout",
|
|
304
|
+
"add one blank line before standalone callouts",
|
|
305
|
+
"warning",
|
|
306
|
+
line=idx + 1,
|
|
307
|
+
)
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
for match in _MALFORMED_ALIAS_RE.finditer(body):
|
|
311
|
+
line = body.count("\n", 0, match.start()) + 1
|
|
312
|
+
warnings.append(
|
|
313
|
+
StyleIssue(
|
|
314
|
+
"malformed_wikilink_alias",
|
|
315
|
+
f"use '[[{match.group(1)}|{match.group(2)}]]' instead of '[[{match.group(1)}]]{match.group(2)}'",
|
|
316
|
+
"warning",
|
|
317
|
+
line=line,
|
|
318
|
+
)
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
for paragraph, start_line in _paragraphs(body):
|
|
322
|
+
if len(paragraph) > 650:
|
|
323
|
+
warnings.append(
|
|
324
|
+
StyleIssue(
|
|
325
|
+
"long_paragraph",
|
|
326
|
+
"split long paragraphs into shorter 2-4 line review blocks",
|
|
327
|
+
"warning",
|
|
328
|
+
line=start_line,
|
|
329
|
+
)
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def _check_didactic_visual_opportunities(body: str, warnings: list[StyleIssue]) -> None:
|
|
334
|
+
if any(zone.kind in {"fenced_mermaid", "display_math"} for zone in protected_markdown_zones(body)):
|
|
335
|
+
return
|
|
336
|
+
h2_matches = list(re.finditer(r"(?m)^##\s+(.+?)\s*$", body))
|
|
337
|
+
for idx, match in enumerate(h2_matches):
|
|
338
|
+
heading_text = match.group(1).strip()
|
|
339
|
+
emoji = heading_text.split(maxsplit=1)[0] if heading_text else ""
|
|
340
|
+
if emoji not in _CLINICAL_VISUAL_H2_EMOJIS:
|
|
341
|
+
continue
|
|
342
|
+
|
|
343
|
+
section_end = h2_matches[idx + 1].start() if idx + 1 < len(h2_matches) else len(body)
|
|
344
|
+
section_text = body[match.start() : section_end]
|
|
345
|
+
if any(zone.kind in {"fenced_mermaid", "display_math"} for zone in protected_markdown_zones(section_text)):
|
|
346
|
+
continue
|
|
347
|
+
|
|
348
|
+
searchable = blank_protected_markdown(section_text)
|
|
349
|
+
suggested_visual, reason = _visual_opportunity(searchable)
|
|
350
|
+
if suggested_visual is None:
|
|
351
|
+
continue
|
|
352
|
+
|
|
353
|
+
line = body.count("\n", 0, match.start()) + 1
|
|
354
|
+
warnings.append(
|
|
355
|
+
StyleIssue(
|
|
356
|
+
"didactic_visual_opportunity",
|
|
357
|
+
"add an embedded Mermaid diagram or display equation when it clarifies this clinical section",
|
|
358
|
+
"warning",
|
|
359
|
+
line=line,
|
|
360
|
+
section=f"## {heading_text}",
|
|
361
|
+
suggested_visual=suggested_visual,
|
|
362
|
+
reason=reason,
|
|
363
|
+
)
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def _visual_opportunity(section_text: str) -> tuple[str | None, str | None]:
|
|
368
|
+
if _EQUATION_KEYWORD_RE.search(section_text):
|
|
369
|
+
return "equation", "secao descreve calculo, formula ou relacao quantitativa que ficaria mais clara como equacao"
|
|
370
|
+
|
|
371
|
+
if _MERMAID_KEYWORD_RE.search(section_text):
|
|
372
|
+
return "mermaid", "secao descreve fluxo, classificacao, algoritmo ou cadeia causal visualizavel"
|
|
373
|
+
|
|
374
|
+
if len(_CAUSAL_CONNECTOR_RE.findall(section_text)) >= 2:
|
|
375
|
+
return "mermaid", "secao encadeia relacoes causais que ficariam mais claras como Mermaid"
|
|
376
|
+
|
|
377
|
+
return None, None
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def _paragraphs(body: str) -> list[tuple[str, int]]:
|
|
381
|
+
paragraphs: list[tuple[str, int]] = []
|
|
382
|
+
current: list[str] = []
|
|
383
|
+
start_line = 1
|
|
384
|
+
in_code = False
|
|
385
|
+
for idx, line in enumerate(body.splitlines(), start=1):
|
|
386
|
+
stripped = line.strip()
|
|
387
|
+
if stripped.startswith("```"):
|
|
388
|
+
in_code = not in_code
|
|
389
|
+
skip = (
|
|
390
|
+
in_code
|
|
391
|
+
or not stripped
|
|
392
|
+
or stripped.startswith(("#", "-", ">", "|", "1.", "2.", "3.", "4.", "5.", "---"))
|
|
393
|
+
)
|
|
394
|
+
if skip:
|
|
395
|
+
if current:
|
|
396
|
+
paragraphs.append((" ".join(current), start_line))
|
|
397
|
+
current = []
|
|
398
|
+
continue
|
|
399
|
+
if not current:
|
|
400
|
+
start_line = idx
|
|
401
|
+
current.append(stripped)
|
|
402
|
+
if current:
|
|
403
|
+
paragraphs.append((" ".join(current), start_line))
|
|
404
|
+
return paragraphs
|