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.
Files changed (430) hide show
  1. package/.opencode/agents/med-chat-triager.md +204 -0
  2. package/.opencode/agents/med-flashcard-maker.md +63 -0
  3. package/.opencode/agents/med-knowledge-architect.md +230 -0
  4. package/.opencode/agents/med-link-graph-curator.md +177 -0
  5. package/.opencode/agents/med-publish-guard.md +62 -0
  6. package/.opencode/commands/flashcards.md +25 -0
  7. package/.opencode/commands/mednotes/create.md +25 -0
  8. package/.opencode/commands/mednotes/enrich.md +27 -0
  9. package/.opencode/commands/mednotes/fix-wiki.md +27 -0
  10. package/.opencode/commands/mednotes/history.md +22 -0
  11. package/.opencode/commands/mednotes/link-body.md +25 -0
  12. package/.opencode/commands/mednotes/link-related.md +27 -0
  13. package/.opencode/commands/mednotes/link.md +27 -0
  14. package/.opencode/commands/mednotes/pdf-library.md +27 -0
  15. package/.opencode/commands/mednotes/process-chats.md +23 -0
  16. package/.opencode/commands/mednotes/setup.md +21 -0
  17. package/.opencode/commands/mednotes/status.md +27 -0
  18. package/.opencode/commands/mednotes/telemetry.md +27 -0
  19. package/.opencode/commands/report.md +26 -0
  20. package/.opencode/mednotes/AGENTS.md +57 -0
  21. package/.opencode/mednotes/agents/med-chat-triager.md +197 -0
  22. package/.opencode/mednotes/agents/med-flashcard-maker.md +56 -0
  23. package/.opencode/mednotes/agents/med-knowledge-architect.md +224 -0
  24. package/.opencode/mednotes/agents/med-link-graph-curator.md +171 -0
  25. package/.opencode/mednotes/agents/med-publish-guard.md +55 -0
  26. package/.opencode/mednotes/contracts/.gitkeep +1 -0
  27. package/.opencode/mednotes/contracts/agents.json +116 -0
  28. package/.opencode/mednotes/contracts/opencode-plugin.json +70 -0
  29. package/.opencode/mednotes/docs/agent-prompt-hardening.md +567 -0
  30. package/.opencode/mednotes/docs/agent-role-contracts.md +94 -0
  31. package/.opencode/mednotes/docs/anki-mcp-twenty-rules.md +214 -0
  32. package/.opencode/mednotes/docs/anki-templates/README.md +39 -0
  33. package/.opencode/mednotes/docs/anki-templates/cloze.back.html +23 -0
  34. package/.opencode/mednotes/docs/anki-templates/cloze.front.html +14 -0
  35. package/.opencode/mednotes/docs/anki-templates/qa.back.html +24 -0
  36. package/.opencode/mednotes/docs/anki-templates/qa.front.html +14 -0
  37. package/.opencode/mednotes/docs/anki-templates/style.css +182 -0
  38. package/.opencode/mednotes/docs/atomicity-splitting-policy.md +113 -0
  39. package/.opencode/mednotes/docs/extension-docs.md +40 -0
  40. package/.opencode/mednotes/docs/flashcard-ingestion.md +278 -0
  41. package/.opencode/mednotes/docs/knowledge-architect.md +208 -0
  42. package/.opencode/mednotes/docs/merge-policy.md +110 -0
  43. package/.opencode/mednotes/docs/public-vocabulary.md +104 -0
  44. package/.opencode/mednotes/docs/semantic-linker.md +141 -0
  45. package/.opencode/mednotes/docs/taxonomy-policy.md +90 -0
  46. package/.opencode/mednotes/docs/triage-policy.md +187 -0
  47. package/.opencode/mednotes/docs/vault-version-control.md +758 -0
  48. package/.opencode/mednotes/docs/vocabulary-db-recovery.md +58 -0
  49. package/.opencode/mednotes/docs/workflow-output-contract.md +779 -0
  50. package/.opencode/mednotes/hooks/hooks.json +79 -0
  51. package/.opencode/mednotes/package-lock.json +6361 -0
  52. package/.opencode/mednotes/package.json +15 -0
  53. package/.opencode/mednotes/pyproject.toml +48 -0
  54. package/.opencode/mednotes/scripts/bootstrap_windows_python_uv.cmd +13 -0
  55. package/.opencode/mednotes/scripts/bootstrap_windows_python_uv.ps1 +172 -0
  56. package/.opencode/mednotes/scripts/enrich_notes.py +23 -0
  57. package/.opencode/mednotes/scripts/full_reset_windows_python_uv.cmd +13 -0
  58. package/.opencode/mednotes/scripts/hooks/antigravity_hook_status.mjs +212 -0
  59. package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/antigravity.mjs +169 -0
  60. package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/harness_payload.mjs +103 -0
  61. package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/opencode_plugin.mjs +341 -0
  62. package/.opencode/mednotes/scripts/hooks/mednotes_hook/adapters/opencode_user_config_sync.mjs +177 -0
  63. package/.opencode/mednotes/scripts/hooks/mednotes_hook/anki_preflight.mjs +214 -0
  64. package/.opencode/mednotes/scripts/hooks/mednotes_hook/cli.mjs +143 -0
  65. package/.opencode/mednotes/scripts/hooks/mednotes_hook/diagnostics.mjs +11 -0
  66. package/.opencode/mednotes/scripts/hooks/mednotes_hook/domain/agent_directive_core.mjs +160 -0
  67. package/.opencode/mednotes/scripts/hooks/mednotes_hook/fsm_directive.mjs +1470 -0
  68. package/.opencode/mednotes/scripts/hooks/mednotes_hook/hook_errors.mjs +120 -0
  69. package/.opencode/mednotes/scripts/hooks/mednotes_hook/retention.mjs +114 -0
  70. package/.opencode/mednotes/scripts/hooks/mednotes_hook/runtime.mjs +174 -0
  71. package/.opencode/mednotes/scripts/hooks/mednotes_hook/telemetry_capture.mjs +511 -0
  72. package/.opencode/mednotes/scripts/hooks/mednotes_hook/vault_guard.mjs +624 -0
  73. package/.opencode/mednotes/scripts/hooks/mednotes_hook.mjs +5 -0
  74. package/.opencode/mednotes/scripts/mednotes/_runtime_paths.py +24 -0
  75. package/.opencode/mednotes/scripts/mednotes/anki_model_validator.py +18 -0
  76. package/.opencode/mednotes/scripts/mednotes/capture_extension_diff.py +1562 -0
  77. package/.opencode/mednotes/scripts/mednotes/feedback_report.py +16 -0
  78. package/.opencode/mednotes/scripts/mednotes/flashcard_index.py +18 -0
  79. package/.opencode/mednotes/scripts/mednotes/flashcard_pipeline.py +18 -0
  80. package/.opencode/mednotes/scripts/mednotes/flashcard_report.py +18 -0
  81. package/.opencode/mednotes/scripts/mednotes/flashcard_sources.py +18 -0
  82. package/.opencode/mednotes/scripts/mednotes/obsidian/README.md +6 -0
  83. package/.opencode/mednotes/scripts/mednotes/obsidian_note_utils.py +20 -0
  84. package/.opencode/mednotes/scripts/mednotes/pdf_library/cli.py +16 -0
  85. package/.opencode/mednotes/scripts/mednotes/project_fsm.py +229 -0
  86. package/.opencode/mednotes/scripts/mednotes/setup_telemetry_email.py +404 -0
  87. package/.opencode/mednotes/scripts/mednotes/sync_anki_twenty_rules.py +18 -0
  88. package/.opencode/mednotes/scripts/mednotes/sync_opencode_user_config.py +36 -0
  89. package/.opencode/mednotes/scripts/mednotes/wiki/cli.py +20 -0
  90. package/.opencode/mednotes/scripts/mednotes/wiki_graph.py +18 -0
  91. package/.opencode/mednotes/scripts/mednotes/wiki_tree.py +134 -0
  92. package/.opencode/mednotes/scripts/reset_windows_python_uv.ps1 +625 -0
  93. package/.opencode/mednotes/scripts/run_python.mjs +109 -0
  94. package/.opencode/mednotes/scripts/vault/vault_commit.ps1 +19 -0
  95. package/.opencode/mednotes/scripts/vault/vault_commit.sh +18 -0
  96. package/.opencode/mednotes/scripts/vault/vault_git.ps1 +19 -0
  97. package/.opencode/mednotes/scripts/vault/vault_git.py +3107 -0
  98. package/.opencode/mednotes/scripts/vault/vault_git.sh +18 -0
  99. package/.opencode/mednotes/scripts/vault/vault_precommit.ps1 +19 -0
  100. package/.opencode/mednotes/scripts/vault/vault_precommit.sh +18 -0
  101. package/.opencode/mednotes/skills/THIRD_PARTY_NOTICES.md +45 -0
  102. package/.opencode/mednotes/skills/create-medical-flashcards/SKILL.md +113 -0
  103. package/.opencode/mednotes/skills/create-medical-note/SKILL.md +90 -0
  104. package/.opencode/mednotes/skills/enrich-medical-note/SKILL.md +120 -0
  105. package/.opencode/mednotes/skills/fix-medical-wiki/SKILL.md +559 -0
  106. package/.opencode/mednotes/skills/link-medical-wiki/SKILL.md +224 -0
  107. package/.opencode/mednotes/skills/obsidian-cli/SKILL.md +118 -0
  108. package/.opencode/mednotes/skills/obsidian-markdown/SKILL.md +207 -0
  109. package/.opencode/mednotes/skills/obsidian-markdown/references/CALLOUTS.md +58 -0
  110. package/.opencode/mednotes/skills/obsidian-markdown/references/EMBEDS.md +63 -0
  111. package/.opencode/mednotes/skills/obsidian-markdown/references/PROPERTIES.md +61 -0
  112. package/.opencode/mednotes/skills/obsidian-ops/SKILL.md +136 -0
  113. package/.opencode/mednotes/skills/pdf-library/SKILL.md +45 -0
  114. package/.opencode/mednotes/skills/process-medical-chats/SKILL.md +246 -0
  115. package/.opencode/mednotes/skills/workflow-report/SKILL.md +100 -0
  116. package/.opencode/mednotes/src/mednotes/__init__.py +5 -0
  117. package/.opencode/mednotes/src/mednotes/domains/__init__.py +5 -0
  118. package/.opencode/mednotes/src/mednotes/domains/flashcards/README.md +26 -0
  119. package/.opencode/mednotes/src/mednotes/domains/flashcards/__init__.py +2 -0
  120. package/.opencode/mednotes/src/mednotes/domains/flashcards/build_demo_apkg.py +177 -0
  121. package/.opencode/mednotes/src/mednotes/domains/flashcards/contracts.py +385 -0
  122. package/.opencode/mednotes/src/mednotes/domains/flashcards/flashcards_machine.py +522 -0
  123. package/.opencode/mednotes/src/mednotes/domains/flashcards/fsm.py +817 -0
  124. package/.opencode/mednotes/src/mednotes/domains/flashcards/index.py +630 -0
  125. package/.opencode/mednotes/src/mednotes/domains/flashcards/install_models.py +445 -0
  126. package/.opencode/mednotes/src/mednotes/domains/flashcards/model.py +359 -0
  127. package/.opencode/mednotes/src/mednotes/domains/flashcards/obsidian_links.py +135 -0
  128. package/.opencode/mednotes/src/mednotes/domains/flashcards/obsidian_note_utils.py +546 -0
  129. package/.opencode/mednotes/src/mednotes/domains/flashcards/pipeline.py +580 -0
  130. package/.opencode/mednotes/src/mednotes/domains/flashcards/report.py +510 -0
  131. package/.opencode/mednotes/src/mednotes/domains/flashcards/sources.py +682 -0
  132. package/.opencode/mednotes/src/mednotes/domains/flashcards/sync_rules.py +184 -0
  133. package/.opencode/mednotes/src/mednotes/domains/history/__init__.py +1 -0
  134. package/.opencode/mednotes/src/mednotes/domains/history/history_fsm.py +852 -0
  135. package/.opencode/mednotes/src/mednotes/domains/history/history_machine.py +453 -0
  136. package/.opencode/mednotes/src/mednotes/domains/setup/__init__.py +7 -0
  137. package/.opencode/mednotes/src/mednotes/domains/setup/setup_fsm.py +808 -0
  138. package/.opencode/mednotes/src/mednotes/domains/setup/setup_machine.py +973 -0
  139. package/.opencode/mednotes/src/mednotes/domains/wiki/README.md +64 -0
  140. package/.opencode/mednotes/src/mednotes/domains/wiki/__init__.py +1 -0
  141. package/.opencode/mednotes/src/mednotes/domains/wiki/api.py +668 -0
  142. package/.opencode/mednotes/src/mednotes/domains/wiki/batch_state.py +102 -0
  143. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/__init__.py +1 -0
  144. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/atomicity/__init__.py +1 -0
  145. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/atomicity/atomicity.py +877 -0
  146. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/body_link/__init__.py +1 -0
  147. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/body_link/body_linker.py +1562 -0
  148. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/effects/__init__.py +1 -0
  149. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/effects/effect_adapters.py +949 -0
  150. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/effects/fix_wiki_runtime_adapters.py +433 -0
  151. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/__init__.py +1 -0
  152. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/coverage.py +413 -0
  153. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/graph.py +396 -0
  154. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/graph/graph_fixes.py +161 -0
  155. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/hygiene/__init__.py +1 -0
  156. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/hygiene/hygiene.py +483 -0
  157. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/__init__.py +2 -0
  158. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/anchors.py +185 -0
  159. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/__init__.py +0 -0
  160. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/cache.py +223 -0
  161. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/config.py +131 -0
  162. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/download.py +224 -0
  163. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/frontmatter.py +59 -0
  164. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/insert.py +227 -0
  165. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/core/local_import.py +54 -0
  166. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/__init__.py +42 -0
  167. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/web_profiles.py +99 -0
  168. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/web_search.py +203 -0
  169. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/illustrate/sources/wikimedia.py +102 -0
  170. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/__init__.py +1 -0
  171. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/markdown_db_adapter.mjs +434 -0
  172. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/markdown_node_runtime.py +274 -0
  173. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/markdown/markdown_query.py +227 -0
  174. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/__init__.py +1 -0
  175. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/artifacts.py +605 -0
  176. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/canonical_merge.py +277 -0
  177. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/markdown_zones.py +85 -0
  178. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/meaning_planner.py +307 -0
  179. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_iter.py +67 -0
  180. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_merge.py +278 -0
  181. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_plan.py +409 -0
  182. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_policy.py +22 -0
  183. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/__init__.py +79 -0
  184. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/fixes.py +264 -0
  185. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/frontmatter.py +435 -0
  186. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/models.py +208 -0
  187. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/prompts.py +37 -0
  188. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/tables.py +236 -0
  189. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/note_style/validate.py +404 -0
  190. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/provenance.py +478 -0
  191. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/raw_chats.py +273 -0
  192. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/notes/sources_backfill.py +235 -0
  193. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/__init__.py +10 -0
  194. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/anchors.py +16 -0
  195. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/captions.py +47 -0
  196. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/cli.py +179 -0
  197. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/cloud.py +52 -0
  198. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/config.py +196 -0
  199. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/context_packets.py +76 -0
  200. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/db.py +81 -0
  201. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/doctor.py +102 -0
  202. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/figure_ids.py +42 -0
  203. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/ingest.py +326 -0
  204. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/insert.py +316 -0
  205. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/mentions.py +57 -0
  206. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/ocr.py +71 -0
  207. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/paths.py +35 -0
  208. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/pdf_engine.py +77 -0
  209. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/schema.py +155 -0
  210. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/search.py +188 -0
  211. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/__init__.py +1 -0
  212. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/app.py +89 -0
  213. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/image_backend.py +29 -0
  214. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/pdf/tui/state.py +65 -0
  215. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/__init__.py +1 -0
  216. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/publish.py +1139 -0
  217. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/publish_receipts.py +365 -0
  218. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/publish/publish_recovery.py +240 -0
  219. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/__init__.py +1 -0
  220. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/agent_behavior_corpus.py +2069 -0
  221. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/agent_report_validation.py +4448 -0
  222. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/agent_run_audit.py +852 -0
  223. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/architect_prompt_eval.py +341 -0
  224. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/body_linker_eval.py +240 -0
  225. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/curator_output_validation.py +175 -0
  226. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/curator_prompt_eval.py +865 -0
  227. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/quality/triager_prompt_eval.py +1295 -0
  228. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/related_notes/__init__.py +1 -0
  229. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/related_notes/related_notes.py +1920 -0
  230. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/related_notes/related_notes_headless.py +1186 -0
  231. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/__init__.py +1 -0
  232. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/plan_attestation.py +148 -0
  233. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/specialist_receipts.py +360 -0
  234. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/specialist_runtime.py +52 -0
  235. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/specialist/specialist_task_runner.py +2470 -0
  236. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/style/__init__.py +1 -0
  237. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/style/style.py +1952 -0
  238. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/subagents/__init__.py +1 -0
  239. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/subagents/agents.py +1767 -0
  240. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/__init__.py +1 -0
  241. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/alias_projection.py +331 -0
  242. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/link_terms.py +151 -0
  243. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/llm_disambiguation.py +182 -0
  244. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/__init__.py +116 -0
  245. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/audit.py +201 -0
  246. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/migration.py +314 -0
  247. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/normalize.py +72 -0
  248. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/policy.py +135 -0
  249. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/resolve.py +413 -0
  250. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/schema.py +157 -0
  251. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/taxonomy/status.py +137 -0
  252. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_bootstrap.py +509 -0
  253. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_curator_batch.py +1115 -0
  254. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_ingestion.py +632 -0
  255. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_map.py +930 -0
  256. package/.opencode/mednotes/src/mednotes/domains/wiki/capabilities/vocabulary/vocabulary_recovery.py +1388 -0
  257. package/.opencode/mednotes/src/mednotes/domains/wiki/cli.py +6665 -0
  258. package/.opencode/mednotes/src/mednotes/domains/wiki/common.py +69 -0
  259. package/.opencode/mednotes/src/mednotes/domains/wiki/config.py +210 -0
  260. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/__init__.py +74 -0
  261. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/agent_report.py +242 -0
  262. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/agent_run_audit.py +196 -0
  263. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/agents.py +601 -0
  264. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/curator.py +256 -0
  265. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/effect_payloads.py +519 -0
  266. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/happy_path.py +190 -0
  267. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/link_git.py +110 -0
  268. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/link_runtime_artifact.py +52 -0
  269. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/note_plan.py +75 -0
  270. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/paths.py +114 -0
  271. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/public_report.py +53 -0
  272. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/publish.py +111 -0
  273. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/raw_coverage.py +217 -0
  274. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/related_notes.py +136 -0
  275. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/related_notes_headless.py +153 -0
  276. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/related_notes_runtime.py +395 -0
  277. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/schema_registry.py +637 -0
  278. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/specialist.py +432 -0
  279. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/status.py +62 -0
  280. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/style_rewrite.py +568 -0
  281. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/vocabulary_ingestion.py +223 -0
  282. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_blockers.py +510 -0
  283. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_guardrails.py +637 -0
  284. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_outcomes.py +121 -0
  285. package/.opencode/mednotes/src/mednotes/domains/wiki/contracts/workflow_receipts.py +100 -0
  286. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/__init__.py +1 -0
  287. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/__init__.py +1 -0
  288. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/__main__.py +4 -0
  289. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/cli.py +275 -0
  290. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/__init__.py +2 -0
  291. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/candidates.py +193 -0
  292. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/cli.py +189 -0
  293. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/gemini.py +220 -0
  294. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/inputs.py +120 -0
  295. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/models.py +34 -0
  296. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/parsing.py +48 -0
  297. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/prompts.py +216 -0
  298. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/quality.py +54 -0
  299. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/reporting.py +24 -0
  300. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/runner.py +433 -0
  301. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/utils.py +39 -0
  302. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/enrich/workflow/vault_guard_bridge.py +17 -0
  303. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/__init__.py +1 -0
  304. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_context_packets.py +454 -0
  305. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_decision_projection.py +133 -0
  306. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_effects.py +1260 -0
  307. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_fsm.py +2768 -0
  308. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_machine.py +1588 -0
  309. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_plan.py +306 -0
  310. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_primary_objective.py +316 -0
  311. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_problem.py +153 -0
  312. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_receipt_evidence.py +306 -0
  313. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_states.py +290 -0
  314. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/fix_wiki_user_report.py +342 -0
  315. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/fix_wiki/health.py +6332 -0
  316. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/__init__.py +1 -0
  317. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_fsm.py +1119 -0
  318. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_git.py +638 -0
  319. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_machine.py +1106 -0
  320. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_retry_governance.py +374 -0
  321. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_runtime_result.py +485 -0
  322. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/link_triggers.py +183 -0
  323. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/linking.py +2758 -0
  324. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/reference_repair.py +718 -0
  325. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link/related_notes_fsm.py +1855 -0
  326. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link_related/__init__.py +1 -0
  327. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/link_related/link_related_machine.py +834 -0
  328. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/__init__.py +1 -0
  329. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_fsm.py +1592 -0
  330. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_machine.py +3097 -0
  331. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_primary_objective.py +28 -0
  332. package/.opencode/mednotes/src/mednotes/domains/wiki/flows/process_chats/process_chats_runtime_result.py +185 -0
  333. package/.opencode/mednotes/src/mednotes/domains/wiki/performance.py +97 -0
  334. package/.opencode/mednotes/src/mednotes/kernel/__init__.py +6 -0
  335. package/.opencode/mednotes/src/mednotes/kernel/agent_directive.py +336 -0
  336. package/.opencode/mednotes/src/mednotes/kernel/base.py +51 -0
  337. package/.opencode/mednotes/src/mednotes/kernel/blockers.py +39 -0
  338. package/.opencode/mednotes/src/mednotes/kernel/effect_executor.py +55 -0
  339. package/.opencode/mednotes/src/mednotes/kernel/effect_intent.py +69 -0
  340. package/.opencode/mednotes/src/mednotes/kernel/effects.py +160 -0
  341. package/.opencode/mednotes/src/mednotes/kernel/errors.py +38 -0
  342. package/.opencode/mednotes/src/mednotes/kernel/fsm_event.py +35 -0
  343. package/.opencode/mednotes/src/mednotes/kernel/fsm_model.py +55 -0
  344. package/.opencode/mednotes/src/mednotes/kernel/fsm_transition_result.py +75 -0
  345. package/.opencode/mednotes/src/mednotes/kernel/guardrails.py +188 -0
  346. package/.opencode/mednotes/src/mednotes/kernel/progress.py +319 -0
  347. package/.opencode/mednotes/src/mednotes/kernel/public_report.py +346 -0
  348. package/.opencode/mednotes/src/mednotes/kernel/state_machine.py +164 -0
  349. package/.opencode/mednotes/src/mednotes/kernel/workflow.py +619 -0
  350. package/.opencode/mednotes/src/mednotes/platform/__init__.py +5 -0
  351. package/.opencode/mednotes/src/mednotes/platform/backup_policy.py +382 -0
  352. package/.opencode/mednotes/src/mednotes/platform/feedback/__init__.py +62 -0
  353. package/.opencode/mednotes/src/mednotes/platform/feedback/cli.py +275 -0
  354. package/.opencode/mednotes/src/mednotes/platform/feedback/contracts.py +83 -0
  355. package/.opencode/mednotes/src/mednotes/platform/feedback/core.py +4168 -0
  356. package/.opencode/mednotes/src/mednotes/platform/feedback/integrity.py +989 -0
  357. package/.opencode/mednotes/src/mednotes/platform/feedback/operational_contract.py +2293 -0
  358. package/.opencode/mednotes/src/mednotes/platform/feedback/telemetry.py +875 -0
  359. package/.opencode/mednotes/src/mednotes/platform/feedback/telemetry_config.py +65 -0
  360. package/.opencode/mednotes/src/mednotes/platform/opencode_runtime_config.py +182 -0
  361. package/.opencode/mednotes/src/mednotes/platform/paths/__init__.py +1560 -0
  362. package/.opencode/mednotes/src/mednotes/platform/secrets.py +89 -0
  363. package/.opencode/mednotes/src/mednotes/platform/user_config.py +103 -0
  364. package/.opencode/mednotes/src/mednotes/platform/vault_guard.py +214 -0
  365. package/.opencode/mednotes/uv.lock +932 -0
  366. package/.opencode/mednotes.generated.json +395 -0
  367. package/.opencode/opencode.json +31 -0
  368. package/.opencode/plugins/mednotes-fsm.mjs +7 -0
  369. package/.opencode/plugins/mednotes_hook/adapters/antigravity.mjs +169 -0
  370. package/.opencode/plugins/mednotes_hook/adapters/harness_payload.mjs +103 -0
  371. package/.opencode/plugins/mednotes_hook/adapters/opencode_plugin.mjs +341 -0
  372. package/.opencode/plugins/mednotes_hook/adapters/opencode_user_config_sync.mjs +177 -0
  373. package/.opencode/plugins/mednotes_hook/anki_preflight.mjs +214 -0
  374. package/.opencode/plugins/mednotes_hook/cli.mjs +143 -0
  375. package/.opencode/plugins/mednotes_hook/diagnostics.mjs +11 -0
  376. package/.opencode/plugins/mednotes_hook/domain/agent_directive_core.mjs +160 -0
  377. package/.opencode/plugins/mednotes_hook/fsm_directive.mjs +1470 -0
  378. package/.opencode/plugins/mednotes_hook/hook_errors.mjs +120 -0
  379. package/.opencode/plugins/mednotes_hook/retention.mjs +114 -0
  380. package/.opencode/plugins/mednotes_hook/runtime.mjs +174 -0
  381. package/.opencode/plugins/mednotes_hook/telemetry_capture.mjs +511 -0
  382. package/.opencode/plugins/mednotes_hook/vault_guard.mjs +624 -0
  383. package/AGENTS.md +57 -0
  384. package/README.md +194 -0
  385. package/adapters/antigravity/agents.json +80 -0
  386. package/adapters/antigravity/templates/med-chat-triager.md +214 -0
  387. package/adapters/antigravity/templates/med-flashcard-maker.md +72 -0
  388. package/adapters/antigravity/templates/med-knowledge-architect.md +241 -0
  389. package/adapters/antigravity/templates/med-link-graph-curator.md +187 -0
  390. package/adapters/antigravity/templates/med-publish-guard.md +71 -0
  391. package/adapters/gemini-cli/gemini-extension.json +14 -0
  392. package/adapters/gemini-cli/package.json +15 -0
  393. package/adapters/gemini-cli/pyproject.toml +48 -0
  394. package/bin/mednotes-opencode.mjs +155 -0
  395. package/contracts/agents.json +116 -0
  396. package/core/agents/med-chat-triager.md +197 -0
  397. package/core/agents/med-flashcard-maker.md +56 -0
  398. package/core/agents/med-knowledge-architect.md +224 -0
  399. package/core/agents/med-link-graph-curator.md +171 -0
  400. package/core/agents/med-publish-guard.md +55 -0
  401. package/core/commands/flashcards.toml +22 -0
  402. package/core/commands/mednotes/create.toml +22 -0
  403. package/core/commands/mednotes/enrich.toml +24 -0
  404. package/core/commands/mednotes/fix-wiki.toml +24 -0
  405. package/core/commands/mednotes/history.toml +19 -0
  406. package/core/commands/mednotes/link-body.toml +22 -0
  407. package/core/commands/mednotes/link-related.toml +24 -0
  408. package/core/commands/mednotes/link.toml +24 -0
  409. package/core/commands/mednotes/pdf-library.toml +24 -0
  410. package/core/commands/mednotes/process-chats.toml +20 -0
  411. package/core/commands/mednotes/setup.toml +18 -0
  412. package/core/commands/mednotes/status.toml +24 -0
  413. package/core/commands/mednotes/telemetry.toml +24 -0
  414. package/core/commands/report.toml +23 -0
  415. package/core/skills/THIRD_PARTY_NOTICES.md +45 -0
  416. package/core/skills/create-medical-flashcards/SKILL.md +113 -0
  417. package/core/skills/create-medical-note/SKILL.md +90 -0
  418. package/core/skills/enrich-medical-note/SKILL.md +120 -0
  419. package/core/skills/fix-medical-wiki/SKILL.md +559 -0
  420. package/core/skills/link-medical-wiki/SKILL.md +224 -0
  421. package/core/skills/obsidian-cli/SKILL.md +118 -0
  422. package/core/skills/obsidian-markdown/SKILL.md +207 -0
  423. package/core/skills/obsidian-markdown/references/CALLOUTS.md +58 -0
  424. package/core/skills/obsidian-markdown/references/EMBEDS.md +63 -0
  425. package/core/skills/obsidian-markdown/references/PROPERTIES.md +61 -0
  426. package/core/skills/obsidian-ops/SKILL.md +136 -0
  427. package/core/skills/pdf-library/SKILL.md +45 -0
  428. package/core/skills/process-medical-chats/SKILL.md +246 -0
  429. package/core/skills/workflow-report/SKILL.md +100 -0
  430. package/package.json +45 -0
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "medical-notes-workbench",
3
+ "version": "0.1.0",
4
+ "description": "Gemini CLI extension packaging for medical notes creation and processing.",
5
+ "private": true,
6
+ "engines": {
7
+ "node": ">=20.17.0"
8
+ },
9
+ "dependencies": {
10
+ "mddb": "^0.9.5"
11
+ },
12
+ "overrides": {
13
+ "sqlite3": "6.0.1"
14
+ }
15
+ }
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "medical-notes-workbench"
7
+ version = "0.1.0"
8
+ description = "Workbench para criar, enriquecer e processar notas médicas Markdown/Obsidian."
9
+ requires-python = ">=3.11"
10
+ dependencies = [
11
+ "cryptography>=45",
12
+ "httpx>=0.27",
13
+ "keyring>=25,<26",
14
+ "Pillow>=10.0",
15
+ "pydantic>=2,<3",
16
+ "python-statemachine>=3.2,<4",
17
+ "PyYAML>=6.0",
18
+ ]
19
+
20
+ [project.optional-dependencies]
21
+ pdf = [
22
+ "pdfplumber>=0.11",
23
+ "pdf2image>=1.17",
24
+ "pytesseract>=0.3.10",
25
+ ]
26
+ pdf-library = [
27
+ "PyMuPDF>=1.24,<2",
28
+ "pytesseract>=0.3.10",
29
+ "textual>=8.2.5",
30
+ "textual-image>=0.12.0; python_full_version >= '3.12'",
31
+ ]
32
+ dev = [
33
+ "pytest>=8.0",
34
+ "pytest-asyncio>=0.23",
35
+ ]
36
+
37
+ [tool.uv]
38
+ required-version = ">=0.11.0"
39
+
40
+ [project.scripts]
41
+ enricher = "enricher.cli:main"
42
+
43
+ [tool.setuptools.packages.find]
44
+ where = ["src"]
45
+
46
+ [tool.pytest.ini_options]
47
+ testpaths = ["tests"]
48
+ asyncio_mode = "auto"
@@ -0,0 +1,13 @@
1
+ @echo off
2
+ setlocal
3
+
4
+ set "SCRIPT_DIR=%~dp0"
5
+ set "BOOTSTRAP=%SCRIPT_DIR%bootstrap_windows_python_uv.ps1"
6
+
7
+ if not exist "%BOOTSTRAP%" (
8
+ echo Bootstrap script not found: %BOOTSTRAP% 1>&2
9
+ exit /b 1
10
+ )
11
+
12
+ powershell -NoProfile -ExecutionPolicy Bypass -File "%BOOTSTRAP%" %*
13
+ exit /b %ERRORLEVEL%
@@ -0,0 +1,172 @@
1
+ #Requires -Version 5.1
2
+ <#
3
+ .SYNOPSIS
4
+ One-command bootstrap for resetting Windows Python to uv for Medical Notes Workbench.
5
+
6
+ .DESCRIPTION
7
+ This script is safe to run from an installed extension or through irm/iex. It
8
+ downloads the latest reset script when possible, falls back to the bundled copy,
9
+ and runs a full reset.
10
+ #>
11
+
12
+ [CmdletBinding()]
13
+ param(
14
+ [string] $ExtensionRoot,
15
+ [string] $Branch = "gemini-cli-extension",
16
+ [switch] $SkipScriptUpdate,
17
+ [switch] $SkipChecks,
18
+ [switch] $NoElevate,
19
+ [switch] $RepairUserVenv,
20
+ [switch] $ElevateForGlobalPythonReset
21
+ )
22
+
23
+ $ErrorActionPreference = "Stop"
24
+
25
+ function Write-Step {
26
+ param([string] $Message)
27
+ Write-Host ""
28
+ Write-Host "==> $Message" -ForegroundColor Cyan
29
+ }
30
+
31
+ function Test-IsAdmin {
32
+ $identity = [Security.Principal.WindowsIdentity]::GetCurrent()
33
+ $principal = New-Object Security.Principal.WindowsPrincipal($identity)
34
+ return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
35
+ }
36
+
37
+ function Invoke-SelfElevatedIfNeeded {
38
+ if ($NoElevate -or (Test-IsAdmin)) {
39
+ return
40
+ }
41
+ if ($RepairUserVenv) {
42
+ Write-Step "Reparando ambiente persistente como usuario atual"
43
+ return
44
+ }
45
+ if (-not $ElevateForGlobalPythonReset) {
46
+ Write-Step "Executando reparo sem elevacao administrativa"
47
+ return
48
+ }
49
+
50
+ if (-not $PSCommandPath) {
51
+ Write-Warning "Nao estou como Administrador e nao consigo auto-elevar script sem arquivo. Continuando mesmo assim."
52
+ return
53
+ }
54
+
55
+ Write-Step "Reabrindo como Administrador"
56
+ $arguments = @(
57
+ "-NoProfile",
58
+ "-ExecutionPolicy",
59
+ "Bypass",
60
+ "-File",
61
+ "`"$PSCommandPath`"",
62
+ "-NoElevate"
63
+ )
64
+ if ($ExtensionRoot) {
65
+ $arguments += @("-ExtensionRoot", "`"$ExtensionRoot`"")
66
+ }
67
+ if ($Branch) {
68
+ $arguments += @("-Branch", "`"$Branch`"")
69
+ }
70
+ if ($SkipScriptUpdate) {
71
+ $arguments += "-SkipScriptUpdate"
72
+ }
73
+ if ($SkipChecks) {
74
+ $arguments += "-SkipChecks"
75
+ }
76
+ if ($RepairUserVenv) {
77
+ $arguments += "-RepairUserVenv"
78
+ }
79
+ if ($ElevateForGlobalPythonReset) {
80
+ $arguments += "-ElevateForGlobalPythonReset"
81
+ }
82
+
83
+ Start-Process -FilePath "powershell.exe" -ArgumentList ($arguments -join " ") -Verb RunAs | Out-Null
84
+ exit 0
85
+ }
86
+
87
+ function Resolve-ExtensionRoot {
88
+ if ($ExtensionRoot) {
89
+ return (Resolve-Path $ExtensionRoot).Path
90
+ }
91
+
92
+ if ($PSScriptRoot) {
93
+ $candidate = (Resolve-Path (Join-Path $PSScriptRoot "..") -ErrorAction SilentlyContinue)
94
+ if ($candidate -and (Test-Path (Join-Path $candidate.Path "pyproject.toml"))) {
95
+ return $candidate.Path
96
+ }
97
+ }
98
+
99
+ $default = Join-Path $HOME ".gemini\extensions\medical-notes-workbench"
100
+ if (Test-Path (Join-Path $default "pyproject.toml")) {
101
+ return $default
102
+ }
103
+
104
+ throw "Nao encontrei a extensao em $default. Instale/atualize medical-notes-workbench primeiro."
105
+ }
106
+
107
+ function Update-ResetScript {
108
+ param(
109
+ [string] $Root,
110
+ [string] $ResetScript
111
+ )
112
+
113
+ if ($SkipScriptUpdate) {
114
+ return
115
+ }
116
+
117
+ $url = "https://raw.githubusercontent.com/augustocaruso/medical-notes-workbench/$Branch/scripts/reset_windows_python_uv.ps1"
118
+ Write-Step "Atualizando reset script"
119
+ try {
120
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
121
+ $content = Invoke-WebRequest -Uri $url -UseBasicParsing
122
+ if (-not $content.Content -or $content.Content -notmatch "param\(") {
123
+ throw "conteudo remoto inesperado"
124
+ }
125
+ New-Item -ItemType Directory -Force (Split-Path -Parent $ResetScript) | Out-Null
126
+ if (Test-Path $ResetScript) {
127
+ Copy-Item -LiteralPath $ResetScript -Destination "$ResetScript.bak" -Force
128
+ }
129
+ Set-Content -LiteralPath $ResetScript -Value $content.Content -Encoding UTF8
130
+ Write-Host "Reset script atualizado: $ResetScript"
131
+ }
132
+ catch {
133
+ Write-Warning "Nao consegui atualizar reset script pelo GitHub: $($_.Exception.Message)"
134
+ if (-not (Test-Path $ResetScript)) {
135
+ throw "Reset script local tambem nao existe: $ResetScript"
136
+ }
137
+ Write-Host "Usando reset script local: $ResetScript"
138
+ }
139
+ }
140
+
141
+ if ([Environment]::OSVersion.Platform -ne [PlatformID]::Win32NT) {
142
+ throw "Este bootstrap e exclusivo para Windows."
143
+ }
144
+
145
+ Invoke-SelfElevatedIfNeeded
146
+
147
+ $root = Resolve-ExtensionRoot
148
+ $resetScript = Join-Path $root "scripts\reset_windows_python_uv.ps1"
149
+
150
+ Update-ResetScript -Root $root -ResetScript $resetScript
151
+
152
+ $resetParams = @{
153
+ ExtensionRoot = $root
154
+ }
155
+ if ($ElevateForGlobalPythonReset -and -not $RepairUserVenv) {
156
+ $resetParams.FullReset = $true
157
+ }
158
+ if ($SkipChecks) {
159
+ $resetParams.SkipChecks = $true
160
+ }
161
+
162
+ if ($RepairUserVenv) {
163
+ Write-Step "Executando reparo do ambiente persistente"
164
+ }
165
+ elseif ($ElevateForGlobalPythonReset) {
166
+ Write-Step "Executando reset completo"
167
+ }
168
+ else {
169
+ Write-Step "Executando reparo sem remocao global"
170
+ }
171
+ & $resetScript @resetParams
172
+ exit $LASTEXITCODE
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python3
2
+ """Public CLI alias for the image enrichment workflow.
3
+
4
+ Thin entrypoint: it only resolves the vendored library path and delegates to
5
+ ``enrich.workflow.cli``. The enrichment library lives at the canonical
6
+ ``src/enrich`` and is vendored into the extension's ``src/`` dir at build time;
7
+ here we put that dir on ``sys.path`` so the import resolves in the shipped
8
+ extension (and falls through to the editable install in dev).
9
+ See ADR-0001 rule 10 (soft layout).
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import sys
14
+ from pathlib import Path
15
+
16
+ _VENDORED_SRC = Path(__file__).resolve().parents[1] / "src"
17
+ if str(_VENDORED_SRC) not in sys.path:
18
+ sys.path.insert(0, str(_VENDORED_SRC))
19
+
20
+ from mednotes.domains.wiki.flows.enrich.workflow.cli import main # noqa: E402
21
+
22
+ if __name__ == "__main__":
23
+ raise SystemExit(main())
@@ -0,0 +1,13 @@
1
+ @echo off
2
+ setlocal
3
+
4
+ set "SCRIPT_DIR=%~dp0"
5
+ set "BOOTSTRAP_SCRIPT=%SCRIPT_DIR%bootstrap_windows_python_uv.ps1"
6
+
7
+ if not exist "%BOOTSTRAP_SCRIPT%" (
8
+ echo Bootstrap script not found: %BOOTSTRAP_SCRIPT% 1>&2
9
+ exit /b 1
10
+ )
11
+
12
+ powershell -NoProfile -ExecutionPolicy Bypass -File "%BOOTSTRAP_SCRIPT%" %*
13
+ exit /b %ERRORLEVEL%
@@ -0,0 +1,212 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs/promises";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const PLUGIN_NAME = "medical-notes-workbench";
9
+ const STATUS_SCHEMA = "medical-notes-workbench.antigravity-hook-status-report.v1";
10
+ const CURRENT_PLUGIN_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
11
+ const GEMINI_EXTENSION_PATH_TOKEN = "${" + "extensionPath}";
12
+ const GEMINI_EXTENSION_HOME_TOKEN = "~/.gemini/" + "extensions/medical-notes-workbench";
13
+ const GEMINI_EXTENSIONS_COMMAND_TOKEN = "gemini " + "extensions ";
14
+ const STALE_RUNTIME_TOKENS = [
15
+ GEMINI_EXTENSION_PATH_TOKEN,
16
+ GEMINI_EXTENSION_HOME_TOKEN,
17
+ GEMINI_EXTENSIONS_COMMAND_TOKEN,
18
+ ];
19
+ const EXPECTED_AGENT_MODELS = new Map([
20
+ ["med-chat-triager.md", "Gemini 3.5 Flash (High)"],
21
+ ["med-publish-guard.md", "Gemini 3.5 Flash (High)"],
22
+ ["med-link-graph-curator.md", "Gemini 3.5 Flash (High)"],
23
+ ["med-flashcard-maker.md", "Gemini 3.1 Pro (High)"],
24
+ ["med-knowledge-architect.md", "Gemini 3.1 Pro (High)"],
25
+ ]);
26
+ const EXPECTED_MODEL_LABELS = new Set(EXPECTED_AGENT_MODELS.values());
27
+ const HOOK_STATUS_FILE = path.join(appHomeDir(), "antigravity-hooks", "status.json");
28
+
29
+ function appHomeDir() {
30
+ return process.env.MEDNOTES_HOME || path.join(os.homedir(), ".mednotes");
31
+ }
32
+
33
+ function compactPath(value) {
34
+ const text = String(value || "");
35
+ if (!text) return "";
36
+ const home = os.homedir();
37
+ return text.startsWith(home) ? `~${text.slice(home.length)}` : text;
38
+ }
39
+
40
+ async function readJson(file) {
41
+ try {
42
+ return JSON.parse(await fs.readFile(file, "utf8"));
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+
48
+ async function hookFileStatus(file) {
49
+ const data = await readJson(file);
50
+ const serialized = data ? JSON.stringify(data) : "";
51
+ return {
52
+ path: compactPath(file),
53
+ exists: Boolean(data),
54
+ antigravity_schema: Boolean(data && !Object.hasOwn(data, "hooks") && serialized.includes("PreToolUse")),
55
+ has_pre_tool_use: serialized.includes("PreToolUse"),
56
+ has_post_tool_use: serialized.includes("PostToolUse"),
57
+ stale_gemini_schema: Boolean(data && Object.hasOwn(data, "hooks")),
58
+ };
59
+ }
60
+
61
+ function frontmatterModel(text) {
62
+ const match = text.match(/^---\r?\n([\s\S]*?)\r?\n---/);
63
+ if (!match) return "";
64
+ const modelLine = match[1].match(/^model:\s*(.+?)\s*$/m);
65
+ if (!modelLine) return "";
66
+ return modelLine[1].replace(/^['"]|['"]$/g, "").trim();
67
+ }
68
+
69
+ async function agentStatus(pluginRoot) {
70
+ const agentsDir = path.join(pluginRoot, "agents");
71
+ try {
72
+ const entries = await fs.readdir(agentsDir, { withFileTypes: true });
73
+ const files = entries
74
+ .filter((entry) => entry.isFile() && entry.name.endsWith(".md"))
75
+ .map((entry) => path.join(agentsDir, entry.name))
76
+ .sort();
77
+ const stale_placeholders = [];
78
+ const models = [];
79
+ const unexpected_models = [];
80
+ for (const file of files) {
81
+ const text = await fs.readFile(file, "utf8");
82
+ for (const token of STALE_RUNTIME_TOKENS) {
83
+ if (text.includes(token)) stale_placeholders.push({ path: compactPath(file), token });
84
+ }
85
+ const filename = path.basename(file);
86
+ const model = frontmatterModel(text);
87
+ const expected = EXPECTED_AGENT_MODELS.get(filename) || "";
88
+ models.push({ path: compactPath(file), model, expected });
89
+ if (expected && model !== expected) {
90
+ unexpected_models.push({ path: compactPath(file), model, expected });
91
+ }
92
+ }
93
+ const model_status = files.length > 0 && unexpected_models.length === 0 ? "ok" : "needs_repair";
94
+ return {
95
+ status: files.length > 0 && stale_placeholders.length === 0 && model_status === "ok" ? "ok" : "needs_repair",
96
+ plugin_root: compactPath(pluginRoot),
97
+ count: files.length,
98
+ files: files.map(compactPath),
99
+ stale_placeholders,
100
+ model_status,
101
+ models,
102
+ unexpected_models,
103
+ };
104
+ } catch {
105
+ return {
106
+ status: "missing",
107
+ plugin_root: compactPath(pluginRoot),
108
+ count: 0,
109
+ files: [],
110
+ stale_placeholders: [],
111
+ model_status: "missing",
112
+ models: [],
113
+ unexpected_models: [],
114
+ };
115
+ }
116
+ }
117
+
118
+ async function selectedModelStatus() {
119
+ const settingsPath = path.join(os.homedir(), ".gemini", "antigravity-cli", "settings.json");
120
+ const settings = await readJson(settingsPath);
121
+ const model = typeof settings?.model === "string" ? settings.model : "";
122
+ return {
123
+ path: compactPath(settingsPath),
124
+ status: model ? "selected" : "missing",
125
+ model,
126
+ matches_plugin_agent_models: model ? EXPECTED_MODEL_LABELS.has(model) : false,
127
+ };
128
+ }
129
+
130
+ async function main(argv = process.argv.slice(2)) {
131
+ const json = argv.includes("--json");
132
+ const configHook = path.join(os.homedir(), ".gemini", "config", "plugins", PLUGIN_NAME, "hooks.json");
133
+ const configNestedHook = path.join(os.homedir(), ".gemini", "config", "plugins", PLUGIN_NAME, "hooks", "hooks.json");
134
+ const importHook = path.join(os.homedir(), ".gemini", "antigravity-cli", "plugins", PLUGIN_NAME, "hooks.json");
135
+ const importNestedHook = path.join(
136
+ os.homedir(),
137
+ ".gemini",
138
+ "antigravity-cli",
139
+ "plugins",
140
+ PLUGIN_NAME,
141
+ "hooks",
142
+ "hooks.json",
143
+ );
144
+ const status = await readJson(HOOK_STATUS_FILE);
145
+ const hook_files = [
146
+ await hookFileStatus(configHook),
147
+ await hookFileStatus(configNestedHook),
148
+ await hookFileStatus(importHook),
149
+ await hookFileStatus(importNestedHook),
150
+ ];
151
+ const agents = await agentStatus(CURRENT_PLUGIN_ROOT);
152
+ const selected_model = await selectedModelStatus();
153
+ const installed = hook_files.some((item) => item.exists && item.antigravity_schema);
154
+ const stale = hook_files.some((item) => item.exists && item.stale_gemini_schema);
155
+ const invocation_seen = Boolean(status?.last_hook?.mode);
156
+ const report = {
157
+ schema: STATUS_SCHEMA,
158
+ status:
159
+ installed && invocation_seen && !stale && agents.status === "ok"
160
+ ? "ok"
161
+ : installed && !stale && agents.status === "ok"
162
+ ? "installed_no_invocation_seen"
163
+ : "needs_repair",
164
+ hook_files,
165
+ agents,
166
+ selected_model,
167
+ heartbeat: status || null,
168
+ next_action: invocation_seen
169
+ ? "Hooks Antigravity foram executados neste ambiente."
170
+ : "Abra ou reinicie a TUI e execute uma ferramenta simples, por exemplo um comando shell; depois rode este status novamente.",
171
+ };
172
+
173
+ if (json) {
174
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
175
+ return;
176
+ }
177
+
178
+ if (report.status === "ok") {
179
+ const last = report.heartbeat.last_hook;
180
+ process.stdout.write(`Hooks Antigravity: OK\n`);
181
+ process.stdout.write(`Ultima execucao: ${report.heartbeat.updated_at}\n`);
182
+ process.stdout.write(`Hook: ${last.mode} (${last.hook_event_name || "evento desconhecido"})\n`);
183
+ process.stdout.write(`Ferramenta: ${last.tool_name || "desconhecida"}\n`);
184
+ process.stdout.write(`Plugin root: ${last.plugin_root || "desconhecido"}\n`);
185
+ process.stdout.write(`Agents: OK (${report.agents.count} arquivos, sem placeholder Gemini antigo)\n`);
186
+ process.stdout.write(`Agent models: OK (${report.agents.model_status})\n`);
187
+ process.stdout.write(`Modelo selecionado: ${report.selected_model.model || "nao detectado"}\n`);
188
+ } else if (report.status === "installed_no_invocation_seen") {
189
+ process.stdout.write("Hooks Antigravity: instalados, mas nenhuma execucao foi registrada ainda.\n");
190
+ process.stdout.write(`Agents: OK (${report.agents.count} arquivos, sem placeholder Gemini antigo)\n`);
191
+ process.stdout.write(`Agent models: OK (${report.agents.model_status})\n`);
192
+ process.stdout.write(`Modelo selecionado: ${report.selected_model.model || "nao detectado"}\n`);
193
+ process.stdout.write(`${report.next_action}\n`);
194
+ } else {
195
+ process.stdout.write("Hooks Antigravity: precisam de reparo.\n");
196
+ for (const item of hook_files) {
197
+ process.stdout.write(
198
+ `- ${item.path}: ${item.exists ? (item.stale_gemini_schema ? "schema Gemini antigo" : "schema Antigravity") : "ausente"}\n`,
199
+ );
200
+ }
201
+ process.stdout.write(`Agents: ${report.agents.status} (${report.agents.count} arquivos)\n`);
202
+ for (const item of report.agents.stale_placeholders) {
203
+ process.stdout.write(`- ${item.path}: placeholder antigo ${item.token}\n`);
204
+ }
205
+ for (const item of report.agents.unexpected_models) {
206
+ process.stdout.write(`- ${item.path}: modelo ${item.model || "ausente"}, esperado ${item.expected}\n`);
207
+ }
208
+ process.stdout.write(`Modelo selecionado: ${report.selected_model.model || "nao detectado"}\n`);
209
+ }
210
+ }
211
+
212
+ await main();
@@ -0,0 +1,169 @@
1
+ import fs from "node:fs/promises";
2
+
3
+ import { firstObject, firstString, normalizedArgs } from "./harness_payload.mjs";
4
+
5
+ const TRANSCRIPT_READ_LIMIT_BYTES = 2 * 1024 * 1024;
6
+
7
+ export function isAntigravityPayload(payload) {
8
+ return Boolean(
9
+ payload &&
10
+ typeof payload === "object" &&
11
+ (payload.toolCall || payload.hookEventName || payload.conversationId || payload.workspacePaths),
12
+ );
13
+ }
14
+
15
+ export function defaultAntigravityHookEventName(mode) {
16
+ if (mode === "capture-after-tool" || mode === "capture-agent-directive-after-tool") return "PostToolUse";
17
+ if (mode === "inject-agent-directive-before-agent") return "PreInvocation";
18
+ if (mode === "validate-agent-directive-after-agent") return "Stop";
19
+ return "PreToolUse";
20
+ }
21
+
22
+ export async function normalizePayloadForRuntime(payload, mode) {
23
+ const raw = payload && typeof payload === "object" ? payload : {};
24
+ if (!isAntigravityPayload(raw)) return raw;
25
+ const transcriptStep = await antigravityTranscriptStep(raw);
26
+ const toolCall = firstObject(raw.toolCall, transcriptStep.toolCall, transcriptStep.tool_call, transcriptStep.toolUse);
27
+ const args = normalizedArgs(toolCall.args || raw.tool_input || raw.toolInput || raw.parameters || raw.args || {});
28
+ const toolName = firstString(
29
+ toolCall.name,
30
+ raw.tool_name,
31
+ raw.toolName,
32
+ raw.name,
33
+ raw.tool,
34
+ transcriptStep.tool_name,
35
+ transcriptStep.toolName,
36
+ );
37
+ const cwd = firstString(args.cwd, raw.cwd, Array.isArray(raw.workspacePaths) ? raw.workspacePaths[0] : "");
38
+ return {
39
+ ...raw,
40
+ hook_event_name: raw.hookEventName || raw.hook_event_name || defaultAntigravityHookEventName(mode),
41
+ session_id: raw.conversationId || raw.session_id || "",
42
+ transcript_path: raw.transcriptPath || raw.transcript_path || "",
43
+ artifact_directory_path: raw.artifactDirectoryPath || raw.artifact_directory_path || "",
44
+ cwd,
45
+ tool_name: toolName,
46
+ original_request_name: toolName,
47
+ tool_input: args,
48
+ tool_response: normalizedToolResponse(
49
+ raw.toolResponse,
50
+ raw.toolResult,
51
+ raw.response,
52
+ raw.result,
53
+ transcriptStep.toolResponse,
54
+ transcriptStep.toolResult,
55
+ transcriptStep.response,
56
+ transcriptStep.result,
57
+ transcriptStep.output,
58
+ transcriptStep.content,
59
+ ),
60
+ antigravity_payload_seen: true,
61
+ };
62
+ }
63
+
64
+ export function renderAntigravityOutput(mode, result, payload) {
65
+ const output = result && typeof result === "object" ? result : {};
66
+ if (mode === "capture-after-tool" || mode === "capture-agent-directive-after-tool") return {};
67
+ const eventName = String(payload?.hook_event_name || "");
68
+ const context = output?.hookSpecificOutput?.additionalContext;
69
+ if (eventName === "PreInvocation" && typeof context === "string" && context.trim()) {
70
+ return {
71
+ injectSteps: [
72
+ {
73
+ ephemeralMessage: context,
74
+ },
75
+ ],
76
+ };
77
+ }
78
+ if (eventName === "Stop") {
79
+ if (output.decision === "deny") {
80
+ return {
81
+ decision: "continue",
82
+ reason: [output.agent_message, output.reason].filter(Boolean).join(" "),
83
+ };
84
+ }
85
+ return {};
86
+ }
87
+ if (eventName === "PreToolUse") {
88
+ if (!output.decision) return { decision: "allow" };
89
+ const details = [output.blocked_reason, output.directive_field, output.agent_message].filter(Boolean).join(" ");
90
+ const reason = [output.reason, details].filter(Boolean).join(" ");
91
+ return {
92
+ decision: output.decision,
93
+ ...(reason ? { reason } : {}),
94
+ };
95
+ }
96
+ if (!output.decision || output.decision === "allow") return {};
97
+ return output;
98
+ }
99
+
100
+ async function antigravityTranscriptStep(raw) {
101
+ const transcriptPath = firstString(raw.transcriptPath, raw.transcript_path);
102
+ if (!transcriptPath) return {};
103
+ try {
104
+ const stats = await fs.stat(transcriptPath);
105
+ if (!stats.isFile() || stats.size > TRANSCRIPT_READ_LIMIT_BYTES) return {};
106
+ const targetStepIdx = stepIndexFromPayload(raw);
107
+ const text = await fs.readFile(transcriptPath, "utf8");
108
+ let fallback = {};
109
+ for (const line of text.split(/\r?\n/)) {
110
+ const record = parseJsonLine(line);
111
+ if (!Object.keys(record).length) continue;
112
+ if (
113
+ record.toolCall ||
114
+ record.toolResponse ||
115
+ record.toolResult ||
116
+ record.response ||
117
+ record.result ||
118
+ record.output
119
+ ) {
120
+ fallback = record;
121
+ }
122
+ if (targetStepIdx && stepIndexFromTranscriptRecord(record) === targetStepIdx) return record;
123
+ }
124
+ return fallback;
125
+ } catch {
126
+ return {};
127
+ }
128
+ }
129
+
130
+ function normalizedToolResponse(...values) {
131
+ for (const value of values) {
132
+ if (value && typeof value === "object" && !Array.isArray(value)) return value;
133
+ if (typeof value === "string" && value.trim()) return { returnDisplay: value };
134
+ }
135
+ return {};
136
+ }
137
+
138
+ function stepIndexFromPayload(payload) {
139
+ return firstString(
140
+ payload?.stepIdx,
141
+ payload?.stepIndex,
142
+ payload?.step_idx,
143
+ payload?.toolStepIdx,
144
+ payload?.toolUseStepIdx,
145
+ );
146
+ }
147
+
148
+ function stepIndexFromTranscriptRecord(record) {
149
+ return firstString(
150
+ record?.stepIdx,
151
+ record?.stepIndex,
152
+ record?.step_idx,
153
+ record?.idx,
154
+ record?.index,
155
+ record?.toolStepIdx,
156
+ record?.toolUseStepIdx,
157
+ );
158
+ }
159
+
160
+ function parseJsonLine(line) {
161
+ const text = String(line || "").trim();
162
+ if (!text) return {};
163
+ try {
164
+ const parsed = JSON.parse(text);
165
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
166
+ } catch {
167
+ return {};
168
+ }
169
+ }