kompend 2026.10.4__py3-none-any.whl

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 (412) hide show
  1. kompend/AGENTS.md +123 -0
  2. kompend/__init__.py +10 -0
  3. kompend/__main__.py +8 -0
  4. kompend/acp/AGENTS.md +65 -0
  5. kompend/acp/__init__.py +24 -0
  6. kompend/acp/builtin/capture.toml +24 -0
  7. kompend/acp/builtin/compile.toml +26 -0
  8. kompend/acp/builtin/generic.toml +28 -0
  9. kompend/acp/builtin/query.toml +28 -0
  10. kompend/acp/definitions.py +130 -0
  11. kompend/acp/harness_adapter.py +65 -0
  12. kompend/acp/provider_store.py +164 -0
  13. kompend/acp/registry.py +151 -0
  14. kompend/acp/tools.py +171 -0
  15. kompend/agents/AGENTS.md +152 -0
  16. kompend/agents/__init__.py +61 -0
  17. kompend/agents/agentic_harness.py +68 -0
  18. kompend/agents/base.py +781 -0
  19. kompend/agents/capture.py +18 -0
  20. kompend/agents/capture_models.py +36 -0
  21. kompend/agents/categorize.py +34 -0
  22. kompend/agents/categorize_models.py +20 -0
  23. kompend/agents/context_chunk.py +17 -0
  24. kompend/agents/context_chunk_agentic.py +70 -0
  25. kompend/agents/context_manager.py +60 -0
  26. kompend/agents/deps.py +168 -0
  27. kompend/agents/distill.py +21 -0
  28. kompend/agents/distill_agentic.py +55 -0
  29. kompend/agents/doctor.py +53 -0
  30. kompend/agents/extraction.py +38 -0
  31. kompend/agents/extraction_reduce.py +25 -0
  32. kompend/agents/generation.py +130 -0
  33. kompend/agents/instrument.py +102 -0
  34. kompend/agents/kompend_model.py +179 -0
  35. kompend/agents/lint.py +58 -0
  36. kompend/agents/query.py +71 -0
  37. kompend/agents/query_agentic.py +56 -0
  38. kompend/agents/reference_extraction.py +37 -0
  39. kompend/agents/reference_resolver.py +41 -0
  40. kompend/agents/remediate.py +81 -0
  41. kompend/agents/rlm.py +371 -0
  42. kompend/agents/search.py +54 -0
  43. kompend/agents/summarizer.py +16 -0
  44. kompend/agents/summarizer_agentic.py +56 -0
  45. kompend/agents/types.py +357 -0
  46. kompend/agents/verification.py +68 -0
  47. kompend/agents/vlm.py +125 -0
  48. kompend/agents/wicer.py +54 -0
  49. kompend/agents/wiki_index.py +67 -0
  50. kompend/agents/write.py +68 -0
  51. kompend/capture/AGENTS.md +32 -0
  52. kompend/capture/__init__.py +5 -0
  53. kompend/capture/_utils.py +41 -0
  54. kompend/capture/capture.py +126 -0
  55. kompend/capture/consolidate.py +175 -0
  56. kompend/capture/distill.py +329 -0
  57. kompend/capture/ingest.py +46 -0
  58. kompend/capture/learn.py +47 -0
  59. kompend/chunking/AGENTS.md +30 -0
  60. kompend/chunking/__init__.py +11 -0
  61. kompend/chunking/contextual.py +202 -0
  62. kompend/chunking/extractors.py +192 -0
  63. kompend/chunking/hierarchical.py +325 -0
  64. kompend/chunking/summarizer.py +262 -0
  65. kompend/cli/AGENTS.md +243 -0
  66. kompend/cli/__init__.py +3 -0
  67. kompend/cli/_ignore.py +132 -0
  68. kompend/cli/_pipeline_helpers.py +240 -0
  69. kompend/cli/_post_compile.py +345 -0
  70. kompend/cli/_progress.py +259 -0
  71. kompend/cli/_query_helpers.py +435 -0
  72. kompend/cli/_shared.py +170 -0
  73. kompend/cli/_sources.py +251 -0
  74. kompend/cli/_sources_io.py +312 -0
  75. kompend/cli/app.py +350 -0
  76. kompend/cli/args/AGENTS.md +168 -0
  77. kompend/cli/args/__init__.py +213 -0
  78. kompend/cli/args/common.py +91 -0
  79. kompend/cli/args/compile.py +98 -0
  80. kompend/cli/args/config.py +31 -0
  81. kompend/cli/args/init.py +66 -0
  82. kompend/cli/args/memory.py +32 -0
  83. kompend/cli/args/other.py +362 -0
  84. kompend/cli/args/parse.py +25 -0
  85. kompend/cli/args/pipeline.py +81 -0
  86. kompend/cli/args/query.py +94 -0
  87. kompend/cli/cmds/AGENTS.md +140 -0
  88. kompend/cli/cmds/__init__.py +55 -0
  89. kompend/cli/cmds/agent.py +68 -0
  90. kompend/cli/cmds/agents.py +194 -0
  91. kompend/cli/cmds/init.py +66 -0
  92. kompend/cli/cmds/knowledge/__init__.py +1 -0
  93. kompend/cli/cmds/knowledge/attachments.py +332 -0
  94. kompend/cli/cmds/knowledge/capture.py +389 -0
  95. kompend/cli/cmds/knowledge/memory.py +118 -0
  96. kompend/cli/cmds/knowledge/organize.py +103 -0
  97. kompend/cli/cmds/knowledge/pack.py +50 -0
  98. kompend/cli/cmds/knowledge/query.py +291 -0
  99. kompend/cli/cmds/knowledge/references.py +200 -0
  100. kompend/cli/cmds/pipeline/__init__.py +1 -0
  101. kompend/cli/cmds/pipeline/config.py +299 -0
  102. kompend/cli/cmds/pipeline/pipeline.py +524 -0
  103. kompend/cli/cmds/pipeline/sources.py +317 -0
  104. kompend/cli/cmds/pipeline/status.py +139 -0
  105. kompend/cli/cmds/quality/__init__.py +1 -0
  106. kompend/cli/cmds/quality/doctor.py +619 -0
  107. kompend/cli/cmds/quality/doctor_cmd.py +67 -0
  108. kompend/cli/cmds/quality/lint.py +606 -0
  109. kompend/cli/cmds/quality/list_parsers_cmd.py +34 -0
  110. kompend/cli/cmds/quality/log.py +73 -0
  111. kompend/cli/cmds/quality/provenance_cmd.py +135 -0
  112. kompend/cli/cmds/quality/review.py +122 -0
  113. kompend/cli/cmds/quality/status_cmd.py +31 -0
  114. kompend/cli/cmds/serve.py +55 -0
  115. kompend/compilation/AGENTS.md +55 -0
  116. kompend/compilation/__init__.py +11 -0
  117. kompend/compilation/_checkpoints.py +143 -0
  118. kompend/compilation/_two_phase_core.py +667 -0
  119. kompend/compilation/asset_mention_rewriter.py +73 -0
  120. kompend/compilation/asset_registry.py +127 -0
  121. kompend/compilation/asset_summarizer.py +49 -0
  122. kompend/compilation/asset_tools.py +99 -0
  123. kompend/compilation/base.py +438 -0
  124. kompend/compilation/concept_broker.py +131 -0
  125. kompend/compilation/concept_keys.py +143 -0
  126. kompend/compilation/context_chunk_tools.py +49 -0
  127. kompend/compilation/distill_tools.py +44 -0
  128. kompend/compilation/extraction_memory.py +251 -0
  129. kompend/compilation/flows/__init__.py +23 -0
  130. kompend/compilation/flows/agentic.py +221 -0
  131. kompend/compilation/flows/assembly.py +373 -0
  132. kompend/compilation/flows/extraction.py +533 -0
  133. kompend/compilation/flows/generation.py +1101 -0
  134. kompend/compilation/flows/references.py +222 -0
  135. kompend/compilation/gen_tools.py +65 -0
  136. kompend/compilation/graph.py +499 -0
  137. kompend/compilation/overview_tools.py +79 -0
  138. kompend/compilation/query_tools.py +74 -0
  139. kompend/compilation/reference_excision.py +98 -0
  140. kompend/compilation/remediate_tools.py +81 -0
  141. kompend/compilation/schema.py +149 -0
  142. kompend/compilation/summarizer_tools.py +46 -0
  143. kompend/compilation/two_phase.py +355 -0
  144. kompend/compilation/verification_tools.py +80 -0
  145. kompend/compilation/wicer.py +474 -0
  146. kompend/compilation/write_tools.py +50 -0
  147. kompend/core/AGENTS.md +48 -0
  148. kompend/core/cache/AGENTS.md +23 -0
  149. kompend/core/cache/__init__.py +7 -0
  150. kompend/core/cache/store.py +358 -0
  151. kompend/core/cache/wiki.py +45 -0
  152. kompend/core/config/AGENTS.md +160 -0
  153. kompend/core/config/__init__.py +89 -0
  154. kompend/core/config/_configs.py +675 -0
  155. kompend/core/config/_core.py +44 -0
  156. kompend/core/config/engine/__init__.py +77 -0
  157. kompend/core/config/engine/_check.py +656 -0
  158. kompend/core/config/engine/_env.py +80 -0
  159. kompend/core/config/engine/_loading.py +169 -0
  160. kompend/core/config/engine/_overlay.py +39 -0
  161. kompend/core/config/engine/_precedence.py +333 -0
  162. kompend/core/config/engine/_schema.py +159 -0
  163. kompend/core/config/generate.py +123 -0
  164. kompend/core/config/keys.py +150 -0
  165. kompend/core/config/rumdl.py +114 -0
  166. kompend/core/env.py +153 -0
  167. kompend/core/models/AGENTS.md +35 -0
  168. kompend/core/models/__init__.py +108 -0
  169. kompend/core/models/assets.py +60 -0
  170. kompend/core/models/attachments.py +388 -0
  171. kompend/core/models/chunks.py +115 -0
  172. kompend/core/models/citations.py +81 -0
  173. kompend/core/models/elements.py +37 -0
  174. kompend/core/models/enums.py +261 -0
  175. kompend/core/models/references.py +163 -0
  176. kompend/core/models/structured.py +225 -0
  177. kompend/core/models/trees.py +163 -0
  178. kompend/core/models/wiki.py +331 -0
  179. kompend/core/page_builder.py +220 -0
  180. kompend/core/paths.py +678 -0
  181. kompend/core/pipeline/AGENTS.md +56 -0
  182. kompend/core/pipeline/__init__.py +5 -0
  183. kompend/core/pipeline/assets.py +132 -0
  184. kompend/core/pipeline/attachments.py +199 -0
  185. kompend/core/pipeline/config.py +314 -0
  186. kompend/core/pipeline/entity_types.py +98 -0
  187. kompend/core/pipeline/export.py +454 -0
  188. kompend/core/pipeline/ingest.py +346 -0
  189. kompend/core/pipeline/orchestrator.py +30 -0
  190. kompend/core/pipeline/parse_cache.py +166 -0
  191. kompend/core/pipeline/references.py +450 -0
  192. kompend/core/pipeline/runtime.py +86 -0
  193. kompend/core/pipeline/stages/__init__.py +7 -0
  194. kompend/core/pipeline/stages/_compile.py +137 -0
  195. kompend/core/pipeline/stages/_factory.py +159 -0
  196. kompend/core/pipeline/stages/_index.py +63 -0
  197. kompend/core/pipeline/stages/_parse.py +519 -0
  198. kompend/core/pipeline/stages/_pipeline.py +404 -0
  199. kompend/core/pipeline/stages/_resolve.py +147 -0
  200. kompend/core/pipeline/state.py +336 -0
  201. kompend/core/reporting/AGENTS.md +25 -0
  202. kompend/core/reporting/__init__.py +5 -0
  203. kompend/core/reporting/log.py +156 -0
  204. kompend/core/reporting/runlog.py +160 -0
  205. kompend/core/resolution/AGENTS.md +23 -0
  206. kompend/core/resolution/__init__.py +5 -0
  207. kompend/core/resolution/entity_registry.py +346 -0
  208. kompend/core/resolution/xref_checker.py +240 -0
  209. kompend/core/source_metadata.py +161 -0
  210. kompend/core/store/AGENTS.md +45 -0
  211. kompend/core/store/__init__.py +32 -0
  212. kompend/core/store/connection.py +119 -0
  213. kompend/core/store/legacy.py +52 -0
  214. kompend/core/store/locate.py +37 -0
  215. kompend/core/store/schema.py +468 -0
  216. kompend/core/templates/AGENTS.md +98 -0
  217. kompend/core/templates/__init__.py +19 -0
  218. kompend/core/templates/loader.py +519 -0
  219. kompend/core/text/embedding_text.py +25 -0
  220. kompend/core/text/encoding.py +159 -0
  221. kompend/core/text/matching.py +182 -0
  222. kompend/core/text/rumdl.py +147 -0
  223. kompend/core/text/slug.py +20 -0
  224. kompend/core/trust/AGENTS.md +25 -0
  225. kompend/core/trust/__init__.py +5 -0
  226. kompend/core/trust/actor.py +39 -0
  227. kompend/core/utils/AGENTS.md +24 -0
  228. kompend/core/utils/__init__.py +5 -0
  229. kompend/core/utils/dicts.py +151 -0
  230. kompend/core/utils/exceptions.py +16 -0
  231. kompend/core/utils/time.py +35 -0
  232. kompend/core/utils/tokens.py +14 -0
  233. kompend/core/verbosity.py +26 -0
  234. kompend/lint/AGENTS.md +37 -0
  235. kompend/lint/__init__.py +35 -0
  236. kompend/lint/_remediation_gaps.py +272 -0
  237. kompend/lint/base.py +129 -0
  238. kompend/lint/flow.py +326 -0
  239. kompend/lint/gap_analysis.py +335 -0
  240. kompend/lint/gap_broker.py +49 -0
  241. kompend/lint/history.py +254 -0
  242. kompend/lint/llm_rules.py +518 -0
  243. kompend/lint/remediation.py +90 -0
  244. kompend/lint/rumdl.toml +22 -0
  245. kompend/lint/runner.py +278 -0
  246. kompend/lint/semantic_gaps.py +184 -0
  247. kompend/lint/structural.py +1335 -0
  248. kompend/llm/AGENTS.md +92 -0
  249. kompend/llm/__init__.py +43 -0
  250. kompend/llm/context_window.py +196 -0
  251. kompend/llm/debug.py +198 -0
  252. kompend/llm/format.py +319 -0
  253. kompend/llm/http_client.py +147 -0
  254. kompend/llm/models.py +483 -0
  255. kompend/llm/postprocess.py +432 -0
  256. kompend/llm/usage.py +132 -0
  257. kompend/llm/user_providers.py +104 -0
  258. kompend/logging.py +109 -0
  259. kompend/mcp/AGENTS.md +36 -0
  260. kompend/mcp/__init__.py +1 -0
  261. kompend/mcp/server.py +163 -0
  262. kompend/mcp/tools/__init__.py +130 -0
  263. kompend/mcp/tools/_helpers.py +39 -0
  264. kompend/mcp/tools/attachments.py +223 -0
  265. kompend/mcp/tools/config.py +161 -0
  266. kompend/mcp/tools/knowledge.py +388 -0
  267. kompend/mcp/tools/memory.py +75 -0
  268. kompend/mcp/tools/packs.py +37 -0
  269. kompend/mcp/tools/pipeline.py +358 -0
  270. kompend/mcp/tools/quality.py +549 -0
  271. kompend/mcp/tools/query.py +149 -0
  272. kompend/mcp/tools/references.py +134 -0
  273. kompend/mcp/tools/sources.py +220 -0
  274. kompend/memory/AGENTS.md +42 -0
  275. kompend/memory/__init__.py +14 -0
  276. kompend/memory/lifecycle.py +353 -0
  277. kompend/memory/store.py +247 -0
  278. kompend/organize/__init__.py +38 -0
  279. kompend/organize/categorize.py +351 -0
  280. kompend/organize/engine.py +204 -0
  281. kompend/organize/moves.py +258 -0
  282. kompend/output/AGENTS.md +82 -0
  283. kompend/output/__init__.py +13 -0
  284. kompend/output/base.py +54 -0
  285. kompend/output/bibtex.py +225 -0
  286. kompend/output/json_writer.py +33 -0
  287. kompend/output/markdown.py +521 -0
  288. kompend/output/models.py +68 -0
  289. kompend/output/pages/__init__.py +21 -0
  290. kompend/output/pages/index.py +238 -0
  291. kompend/output/pages/log.py +326 -0
  292. kompend/output/pages/overview.py +165 -0
  293. kompend/output/reference_links.py +302 -0
  294. kompend/output/renderer.py +236 -0
  295. kompend/output/typst.py +90 -0
  296. kompend/output/vault.py +870 -0
  297. kompend/output/wiki_index.py +25 -0
  298. kompend/packs/AGENTS.md +68 -0
  299. kompend/packs/__init__.py +15 -0
  300. kompend/packs/base.py +174 -0
  301. kompend/packs/builtins/__init__.py +9 -0
  302. kompend/packs/builtins/academic/__init__.py +5 -0
  303. kompend/packs/builtins/academic/pack.toml +14 -0
  304. kompend/packs/builtins/default/pack.toml +16 -0
  305. kompend/packs/builtins/technical/__init__.py +5 -0
  306. kompend/packs/builtins/technical/pack.toml +14 -0
  307. kompend/preprocessing/__init__.py +3 -0
  308. kompend/preprocessing/dedup/__init__.py +16 -0
  309. kompend/preprocessing/dedup/base.py +107 -0
  310. kompend/preprocessing/dedup/embedding_matcher.py +114 -0
  311. kompend/preprocessing/dedup/minhash_matcher.py +152 -0
  312. kompend/preprocessing/dedup/orchestrator.py +329 -0
  313. kompend/preprocessing/dedup/store.py +231 -0
  314. kompend/preprocessing/downloaders/__init__.py +24 -0
  315. kompend/preprocessing/downloaders/base.py +15 -0
  316. kompend/preprocessing/downloaders/crawler.py +209 -0
  317. kompend/preprocessing/downloaders/duplicate_detector.py +97 -0
  318. kompend/preprocessing/downloaders/http_downloader.py +236 -0
  319. kompend/preprocessing/downloaders/url_resolver.py +247 -0
  320. kompend/preprocessing/parsers/AGENTS.md +133 -0
  321. kompend/preprocessing/parsers/__init__.py +44 -0
  322. kompend/preprocessing/parsers/_registry.py +243 -0
  323. kompend/preprocessing/parsers/base.py +210 -0
  324. kompend/preprocessing/parsers/markdown.py +102 -0
  325. kompend/preprocessing/parsers/parsecraft_parser.py +497 -0
  326. kompend/provenance.py +75 -0
  327. kompend/rag/AGENTS.md +83 -0
  328. kompend/rag/__init__.py +53 -0
  329. kompend/rag/zvec_store.py +904 -0
  330. kompend/resolution/__init__.py +9 -0
  331. kompend/resolution/base.py +27 -0
  332. kompend/resolution/chain.py +43 -0
  333. kompend/resolution/vlm_enricher.py +203 -0
  334. kompend/review.py +206 -0
  335. kompend/scaffolding/__init__.py +23 -0
  336. kompend/scaffolding/_core.py +425 -0
  337. kompend/scaffolding/templates/AGENTS.md.j2 +95 -0
  338. kompend/scaffolding/templates/NOTES.md +22 -0
  339. kompend/scaffolding/templates/README.md.j2 +40 -0
  340. kompend/scaffolding/templates/gitignore.j2 +11 -0
  341. kompend/scaffolding/templates/next_steps.txt.j2 +4 -0
  342. kompend/search/AGENTS.md +37 -0
  343. kompend/search/adaptive_retriever.py +173 -0
  344. kompend/search/budget.py +215 -0
  345. kompend/search/classifier.py +157 -0
  346. kompend/search/filters.py +43 -0
  347. kompend/search/pipeline.py +328 -0
  348. kompend/search/retriever.py +613 -0
  349. kompend/templates/capture/capture_system.md.j2 +47 -0
  350. kompend/templates/capture/distill.md.j2 +43 -0
  351. kompend/templates/capture/distill_agentic_prompt.md.j2 +15 -0
  352. kompend/templates/capture/distill_agentic_system.md.j2 +26 -0
  353. kompend/templates/capture/write_agentic_prompt.md.j2 +1 -0
  354. kompend/templates/capture/write_agentic_system.md.j2 +23 -0
  355. kompend/templates/capture/write_prompt.md.j2 +17 -0
  356. kompend/templates/chunking/contextual_agentic_prompt.md.j2 +8 -0
  357. kompend/templates/chunking/contextual_agentic_system.md.j2 +17 -0
  358. kompend/templates/chunking/contextual_context.md.j2 +8 -0
  359. kompend/templates/chunking/node_summary.md.j2 +26 -0
  360. kompend/templates/chunking/summarizer_agentic_prompt.md.j2 +10 -0
  361. kompend/templates/chunking/summarizer_agentic_system.md.j2 +29 -0
  362. kompend/templates/compilation/extraction_prompt.md.j2 +12 -0
  363. kompend/templates/compilation/extraction_reduce_prompt.md.j2 +14 -0
  364. kompend/templates/compilation/extraction_reduce_system.md.j2 +6 -0
  365. kompend/templates/compilation/extraction_system.md.j2 +24 -0
  366. kompend/templates/compilation/generation_agentic_prompt.md.j2 +46 -0
  367. kompend/templates/compilation/generation_agentic_system.md.j2 +42 -0
  368. kompend/templates/compilation/generation_prompt.md.j2 +62 -0
  369. kompend/templates/compilation/generation_system.md.j2 +26 -0
  370. kompend/templates/compilation/reference_extraction_prompt.md.j2 +14 -0
  371. kompend/templates/compilation/reference_extraction_system.md.j2 +25 -0
  372. kompend/templates/compilation/reference_resolver_prompt.md.j2 +14 -0
  373. kompend/templates/compilation/reference_resolver_system.md.j2 +19 -0
  374. kompend/templates/compilation/wicer_diagnose.md.j2 +12 -0
  375. kompend/templates/compilation/wicer_evaluate.md.j2 +17 -0
  376. kompend/templates/compilation/wicer_probe.md.j2 +9 -0
  377. kompend/templates/lint/clarity-score.md.j2 +15 -0
  378. kompend/templates/lint/contradiction-detection.md.j2 +38 -0
  379. kompend/templates/lint/coverage-gap-dedup.md.j2 +27 -0
  380. kompend/templates/lint/coverage-gap.md.j2 +24 -0
  381. kompend/templates/lint/factual-consistency.md.j2 +15 -0
  382. kompend/templates/lint/remediate_agentic_prompt.md.j2 +16 -0
  383. kompend/templates/lint/remediate_agentic_system.md.j2 +30 -0
  384. kompend/templates/lint/remediate_concept.md.j2 +46 -0
  385. kompend/templates/lint/verify_agentic_prompt.md.j2 +2 -0
  386. kompend/templates/lint/verify_agentic_system.md.j2 +20 -0
  387. kompend/templates/memory/system_context.md.j2 +9 -0
  388. kompend/templates/organize/categorize_prompt.md.j2 +14 -0
  389. kompend/templates/organize/categorize_system.md.j2 +48 -0
  390. kompend/templates/output/synthesize.md.j2 +16 -0
  391. kompend/templates/output/synthesize_agentic_prompt.md.j2 +9 -0
  392. kompend/templates/output/synthesize_agentic_system.md.j2 +23 -0
  393. kompend/templates/query/synthesize_system.md.j2 +42 -0
  394. kompend/templates/search/crag_grade.md.j2 +10 -0
  395. kompend/templates/search/expand_query.md.j2 +26 -0
  396. kompend/templates/search/hyde_generate.md.j2 +5 -0
  397. kompend/templates/search/query_agentic_prompt.md.j2 +25 -0
  398. kompend/templates/search/query_agentic_system.md.j2 +25 -0
  399. kompend/templates/verification/verify_claim.md.j2 +21 -0
  400. kompend/templates/verification/verify_system.md.j2 +7 -0
  401. kompend/trust.py +206 -0
  402. kompend/types.py +77 -0
  403. kompend/verification.py +231 -0
  404. kompend/web/_view_helpers.py +60 -0
  405. kompend/web/routes_api.py +38 -0
  406. kompend/web/routes_pages.py +420 -0
  407. kompend/web/server.py +27 -0
  408. kompend-2026.10.4.dist-info/METADATA +225 -0
  409. kompend-2026.10.4.dist-info/RECORD +412 -0
  410. kompend-2026.10.4.dist-info/WHEEL +4 -0
  411. kompend-2026.10.4.dist-info/entry_points.txt +2 -0
  412. kompend-2026.10.4.dist-info/licenses/LICENSE +21 -0
kompend/AGENTS.md ADDED
@@ -0,0 +1,123 @@
1
+ # DOX — kompend Python source tree
2
+
3
+ <!-- on entry: loaded when agent enters src/kompend/ -->
4
+ <!-- parent: ../../AGENTS.md | .agents/POLICIES.md, .agents/CODE.md, .agents/CODE.md, .agents/FILES.md, .agents/CHECKS.md -->
5
+
6
+ ## Purpose
7
+
8
+ Coding conventions and quality standards for the kompend Python source tree at
9
+ `src/kompend/`. Governs how Python code is written and how human-readable text is
10
+ handled. Code policies (antipatterns, boundaries, error handling) are universal
11
+ and live in `.agents/CODE.md`.
12
+
13
+ ## Ownership
14
+
15
+ - `src/kompend/` — all kompend Python source code
16
+ - `src/kompend/templates/` — all LLM prompt and instruction templates
17
+ - `src/kompend/packs/` — prompt packs (see `packs/AGENTS.md`)
18
+
19
+ ## Local Contracts
20
+
21
+ ### No text in code
22
+
23
+ **LLM prompts, system instructions, template strings, configuration data, and
24
+ any other human-readable text must NOT be embedded in Python source files.**
25
+ Text in string constants is invisible to the domain experts who review prompts,
26
+ editable only by touching Python, versioned with code that has a different
27
+ review cycle, and unverifiable by tooling.
28
+
29
+ | Content | Format | Location |
30
+ | ------- | ------ | -------- |
31
+ | LLM system/user prompts | Jinja2 (`.md.j2`) | `templates/<module>/<role>_system.md.j2` |
32
+ | Page kind definitions | TOML | `<module>/kinds.toml` or config |
33
+ | Pack prompts and roles | TOML | `packs/<name>/pack.toml` |
34
+ | Any other human-readable string | TOML / Jinja2 | the appropriate config dir |
35
+
36
+ **Acceptable exceptions:** short (≤5 words) status messages to `typer.echo()` or
37
+ a logger; error messages that must name code-level constructs (variables,
38
+ types); single words as enum members, dict keys, or field names; docstrings and
39
+ type annotations.
40
+
41
+ Template layout, loader search order, frontmatter schema, and variable
42
+ validation — see `core/templates/AGENTS.md`. Pack layout — see
43
+ `packs/AGENTS.md`. Known legacy violations — see `.agents/HISTORY.md`.
44
+
45
+ ### Python antipatterns
46
+
47
+ Antipattern table, code boundaries (config fields, no absolute paths, no
48
+ `TYPE_CHECKING`, banned suppressions, lazy heavy deps), and the error-handling
49
+ policy — **see `.agents/CODE.md`**. They apply to production code and tests
50
+ alike. Two are enforced by script; run both before committing (see
51
+ `.agents/CHECKS.md`).
52
+
53
+ ### Output format — OKF v0.2
54
+
55
+ kompend emits **OKF v0.2** bundles by default; OKF is a compliance spec, not an
56
+ output format. Conformance rules (frontmatter, trust fields, provenance fields,
57
+ portable cross-links, reserved filenames, page kinds, footnote attribution,
58
+ permissive consumption) — **see `output/AGENTS.md`** and
59
+ `docs/concepts/open-knowledge-format.md`. Generated output is rumdl-clean: there
60
+ is one markdown writer, no exempt variants.
61
+
62
+ ### LLM agents
63
+
64
+ Every LLM call routes through the PydanticAI agents in `agents/` — class
65
+ hierarchy, `KompendAgentBase` responsibilities, `KompendModel`, deps types, and the
66
+ rules for adding an agent — **see `agents/AGENTS.md`**. Model construction goes
67
+ through `kompend.llm.models.build_model()`; see `llm/AGENTS.md`.
68
+
69
+ ### ACP agent
70
+
71
+ The Agent Client Protocol adapter (`kompend agent` on stdio) — protocol flow,
72
+ module map, and modification guidance — **see `acp/AGENTS.md`** and
73
+ `docs/integrations/acp-agent.md`.
74
+
75
+ ## Work Guidance
76
+
77
+ - Python 3.11+ only. Modern typing (`X | None`, `list[str]`).
78
+ - Every module in `src/kompend/` has an `__init__.py` that defines its public API
79
+ via re-exports. Import from the package root, not the defining submodule.
80
+ - `src/kompend/core/paths.py` is the single source of truth for on-disk artifact
81
+ paths — see `.agents/FILES.md`.
82
+ - `src/kompend/core/config/` owns all configuration and `DEFAULTS` — see
83
+ `core/config/AGENTS.md`.
84
+ - Heavy optional dependencies stay lazy so CLI startup stays fast — pattern in
85
+ `.agents/CODE.md`.
86
+
87
+ ## Verification
88
+
89
+ Commands — see `.agents/CHECKS.md`. For this subtree the relevant ones are
90
+ `ruff check`, `ty check src/ tests/`, `pytest tests/unit`, and the two AST gates.
91
+ `mise lint` and `mise typecheck` wrap the first two.
92
+
93
+ ## Child DOX Index
94
+
95
+ | Path | Scope |
96
+ | ---- | ----- |
97
+ | `acp/` | ACP adapter — TOML-defined conversational agents, tool set, provider store |
98
+ | `agents/` | PydanticAI agents for every LLM call; `KompendAgentBase`, `KompendModel`, deps |
99
+ | `capture/` | Capture/distill/learn pipeline for URLs, files, stdin |
100
+ | `chunking/` | Tier 2 — split parsed documents into context-window-sized `ChunkTree` |
101
+ | `cli/` | CLI shell over the core library — Typer commands, argument declarations |
102
+ | `cli/args/` | All CLI argument/option definitions (`Annotated` aliases) |
103
+ | `cli/cmds/` | All CLI command entry points, organized by domain |
104
+ | `compilation/` | Tier 4 — knowledge graph build, WiCER loop, page kinds |
105
+ | `core/` | Foundation — models, pipeline, config, cache, templates, trust, utils |
106
+ | `core/cache/` | Content-addressed JSON cache with dependency validation |
107
+ | `core/config/` | Configuration resolution engine and `DEFAULTS` |
108
+ | `core/models/` | Canonical data models and serialization contracts |
109
+ | `core/pipeline/` | Tier orchestration, pipeline config, tier state, ingest |
110
+ | `core/reporting/` | On-demand report builders for CLI observability |
111
+ | `core/resolution/` | Tier 3 — entity extraction/dedup, cross-reference checking |
112
+ | `core/store/` | The vault SQLite store (`.kompend/kompend.db`) |
113
+ | `core/templates/` | Jinja2 loading, frontmatter parsing, variable validation |
114
+ | `core/trust/` | Actor identity and trust/privacy concerns |
115
+ | `core/utils/` | Pure helpers, zero domain logic |
116
+ | `lint/` | Structural + LLM lint rules, gap analysis, remediation |
117
+ | `llm/` | Model construction, context-window discovery, formats, usage tracking |
118
+ | `mcp/` | MCP server exposing kompend operations as tools (fastmcp) |
119
+ | `memory/` | Query memory store and compile-time lifecycle |
120
+ | `output/` | Tier 5 — OKF markdown/JSON/Typst writers, indexes, log |
121
+ | `preprocessing/parsers/` | Pluggable ingestion backends and their registry |
122
+ | `rag/` | zvec vector store — fields, index build, filters, drift, pruning |
123
+ | `search/` | Multi-retriever semantic search with adaptive selection |
kompend/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ """kompend package."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib.metadata
6
+
7
+ try:
8
+ __version__ = importlib.metadata.version(__name__)
9
+ except importlib.metadata.PackageNotFoundError:
10
+ __version__ = "0.0.0" # Fallback for development mode
kompend/__main__.py ADDED
@@ -0,0 +1,8 @@
1
+ """Entry point for My Project CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from kompend.cli.app import main
6
+
7
+ if __name__ == "__main__":
8
+ main()
kompend/acp/AGENTS.md ADDED
@@ -0,0 +1,65 @@
1
+ # DOX — kompend.acp
2
+
3
+ <!-- on entry: loaded when agent enters src/kompend/acp -->
4
+ <!-- parent: ../../../AGENTS.md | .agents/POLICIES.md, .agents/CODE.md, .agents/CODE.md, .agents/FILES.md, .agents/CHECKS.md -->
5
+
6
+ ## Purpose
7
+
8
+ ACP (Agent Client Protocol) adapter — serve kompend to editors and AI agents over
9
+ stdio (`kompend agent`) with TOML-defined conversational agents. The client injects
10
+ its own LLM endpoint through `providers/set`, so kompend carries no credentials of
11
+ its own. User-facing guide: `docs/integrations/acp-agent.md`.
12
+
13
+ ## Ownership
14
+
15
+ - `src/kompend/acp/` — agent definitions, registry, tool set, provider store,
16
+ harness adapter, shipped agent TOML
17
+
18
+ ## Architecture
19
+
20
+ | Module | Contents |
21
+ | ------ | -------- |
22
+ | `definitions.py` | `AgentDefinition`, `AgentTask`, `AgentLLMConfig`, `AgentPromptConfig` — the TOML schema |
23
+ | `registry.py` | `AgentRegistry` — discovery (built-in / vault / explicit), `active_for` resolution |
24
+ | `tools.py` | Native PydanticAI `FunctionToolset` wrapping the MCP server functions; `base_dir` injected by closure |
25
+ | `harness_adapter.py` | `build_kompend_agent`, `kompend_session_config` — per-session agent factory for `run_acp_stdio_sync` |
26
+ | `provider_store.py` | Thread-safe store for the `providers/set` endpoint; reconfigures env-var-based model resolution |
27
+ | `builtin/*.toml` | Shipped agents: `generic`, `compile`, `query`, `capture` |
28
+
29
+ Protocol flow: `initialize` (advertises `providers` capability) → `providers/list`
30
+ → `providers/set` (endpoint stored, model reconfigured) → `session/new` →
31
+ prompts. `/kompend <command>` prompts dispatch the corresponding CLI command; free
32
+ text goes to the active conversational agent. The protocol itself is handled by
33
+ `pydantic-ai-harness` (`run_acp_stdio_sync`), not by this package.
34
+
35
+ ## Local Contracts
36
+
37
+ - Import: `from kompend.acp.registry import AgentRegistry`,
38
+ `from kompend.acp.definitions import AgentDefinition`.
39
+ - Agent definitions live in TOML, never in Python source (see `AGENTS.md`:
40
+ "no text in code"). Built-ins ship in `builtin/*.toml`; user agents go in
41
+ `<wiki>/.kompend/agents/*.toml`. The active agent per task is stored in
42
+ `config.toml` under `[agents]`.
43
+ - `providers/set` is an RFD, not stable ACP. When it is never called, model
44
+ resolution falls back to env vars → `config.toml` → `DEFAULTS`.
45
+ - Sessions are stateless: each prompt turn is independent, with no accumulated
46
+ conversation history.
47
+ - Tools are the MCP server's functions — add a tool by adding an MCP tool, not a
48
+ parallel implementation.
49
+ - `ProviderCredentials` is thread-safe (`threading.Lock`) and restores the
50
+ previous environment on `disable()`.
51
+
52
+ ## Work Guidance
53
+
54
+ - New built-in agent: add TOML under `builtin/` with a name, description, system
55
+ prompt, and tool list; no Python change is required.
56
+ - New provider method (`providers/*`): extend the `ext_method` handler in the
57
+ harness adapter and `provider_store.py`.
58
+ - Reaching the pipeline from a tool: call the core function or the CLI helper
59
+ that the MCP tool calls — never shell out.
60
+
61
+ ## Verification
62
+
63
+ - `uv run pytest tests/unit/test_agent.py tests/unit/test_agent_definitions.py -q`
64
+ — provider store, credentials, agent install/remove, definitions, registry.
65
+ The protocol itself lives in `pydantic-ai-harness` and is not covered here.
@@ -0,0 +1,24 @@
1
+ """ACP agent — kompend as an ACP-compatible agent for credential-free LLM injection.
2
+
3
+ Heavy submodules (``harness_adapter`` → pydantic-ai + the MCP server chain) are
4
+ imported lazily via ``lazy_loader``, so importing anything under ``kompend.acp.*``
5
+ — e.g. the lightweight :mod:`kompend.acp.definitions` enum used by the CLI — does
6
+ not pull in pydantic-ai, the MCP server, and the agent/pipeline stack on every
7
+ ``kompend`` invocation (notably ``--help``). Pattern per scientific-python
8
+ SPEC-0001; ``EAGER_IMPORT=1`` disables it for debugging.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import lazy_loader as lazy
14
+
15
+ __getattr__, __dir__, __all__ = lazy.attach(
16
+ __name__,
17
+ submodules=["definitions", "registry", "provider_store"],
18
+ submod_attrs={
19
+ "definitions": ["AgentDefinition", "AgentTask"],
20
+ "registry": ["AgentRegistry"],
21
+ "provider_store": ["LlmApiType", "ProviderConfig", "ProviderCredentials"],
22
+ "harness_adapter": ["build_kompend_agent", "kompend_session_config"],
23
+ },
24
+ )
@@ -0,0 +1,24 @@
1
+ name = "note-taker"
2
+ description = "Capture-focused agent — helps capture notes, decisions, and observations into the knowledge base."
3
+ task = "capture"
4
+
5
+ [llm]
6
+ temperature = 0.4
7
+ max_tokens = 2048
8
+
9
+ [prompt]
10
+ system = """\
11
+ You are a kompend note-taking assistant. You help users capture decisions, \
12
+ discoveries, corrections, and references into the knowledge base.
13
+
14
+ When the user shares a note or observation, use wiki_capture to extract \
15
+ structured knowledge items from it. Confirm what was captured and suggest \
16
+ tags if appropriate.
17
+ """
18
+
19
+ [tools]
20
+ enabled = ["wiki_capture", "wiki_status"]
21
+
22
+ [behavior]
23
+ max_turns = 5
24
+ stream_progress = true
@@ -0,0 +1,26 @@
1
+ name = "compiler"
2
+ description = "Compilation-focused agent — helps compile, recompile, and lint the knowledge wiki."
3
+ task = "compile"
4
+
5
+ [llm]
6
+ temperature = 0.2
7
+ max_tokens = 4096
8
+
9
+ [prompt]
10
+ system = """\
11
+ You are a kompend compilation assistant. Your primary job is to help the user \
12
+ compile documents into a structured knowledge wiki.
13
+
14
+ Before compiling, check the wiki status. After compiling, report the result \
15
+ (page count, duration, any issues). Offer to lint if the compilation succeeded.
16
+
17
+ If the user asks to change compilation settings, use config_get/config_set. \
18
+ Always confirm before triggering a recompile (it may take a long time).
19
+ """
20
+
21
+ [tools]
22
+ enabled = ["compile_wiki", "wiki_status", "config_get", "config_set"]
23
+
24
+ [behavior]
25
+ max_turns = 8
26
+ stream_progress = true
@@ -0,0 +1,28 @@
1
+ name = "generic"
2
+ description = "Generic kompend assistant — handles any task by reasoning over available tools. Always available as fallback."
3
+ task = "generic"
4
+
5
+ [llm]
6
+ temperature = 0.3
7
+ max_tokens = 4096
8
+
9
+ [prompt]
10
+ system = """\
11
+ You are a kompend knowledge base assistant. You help users compile, query, \
12
+ capture, and organize documents into a structured wiki.
13
+
14
+ Use the available tools to accomplish the user's request. If the request \
15
+ is ambiguous, ask for clarification before proceeding. Report results \
16
+ clearly and concisely.
17
+
18
+ Available operations:
19
+ - Compile sources into a wiki (compile_wiki)
20
+ - Query the compiled wiki (query_wiki)
21
+ - Capture notes and learn from content (wiki_capture, wiki_learn)
22
+ - Check wiki status and health (wiki_status)
23
+ - Read and modify configuration (config_get, config_set)
24
+ """
25
+
26
+ [behavior]
27
+ max_turns = 10
28
+ stream_progress = true
@@ -0,0 +1,28 @@
1
+ name = "researcher"
2
+ description = "Query-focused agent — answers questions about the compiled wiki using retrieval-augmented generation."
3
+ task = "query"
4
+
5
+ [llm]
6
+ temperature = 0.3
7
+ max_tokens = 4096
8
+
9
+ [prompt]
10
+ system = """\
11
+ You are a kompend research assistant. You answer questions about the compiled \
12
+ knowledge wiki using the query_wiki tool.
13
+
14
+ When a user asks a question:
15
+ 1. Call query_wiki with their question
16
+ 2. Synthesize a clear, factual answer from the results
17
+ 3. Cite source pages when relevant
18
+
19
+ If no wiki is compiled, inform the user and suggest running a compilation first. \
20
+ If the question is ambiguous, ask for clarification.
21
+ """
22
+
23
+ [tools]
24
+ enabled = ["query_wiki", "wiki_status"]
25
+
26
+ [behavior]
27
+ max_turns = 6
28
+ stream_progress = true
@@ -0,0 +1,130 @@
1
+ """Pydantic models for TOML-defined conversational agents.
2
+
3
+ Each agent is a single TOML file with a system prompt, tool list, and
4
+ optional model/behavior configuration. Loaded by :class:`AgentRegistry`.
5
+
6
+ TOML schema::
7
+
8
+ name = "wiki-compiler"
9
+ description = "Compiles documents into a knowledge wiki"
10
+ task = "compile" # compile | query | capture | organize | generic
11
+
12
+ [llm]
13
+ model = null # null = vault default
14
+ temperature = 0.2
15
+ max_tokens = 4096
16
+
17
+ [prompt]
18
+ system = "You are a kompend compilation assistant..."
19
+
20
+ [tools]
21
+ enabled = ["compile_wiki", "wiki_status"] # null/omitted = all tools
22
+
23
+ [behavior]
24
+ max_turns = 10
25
+ stream_progress = true
26
+ """
27
+
28
+ from __future__ import annotations
29
+
30
+ import tomllib
31
+ from enum import StrEnum
32
+ from pathlib import Path
33
+ from typing import Any
34
+
35
+ from pydantic import BaseModel, ConfigDict, Field
36
+
37
+
38
+ class AgentTask(StrEnum):
39
+ """User-facing task categories for agent selection.
40
+
41
+ Tasks map to the kind of operation the user wants to perform, not to
42
+ individual LLM calls within the pipeline.
43
+ """
44
+
45
+ COMPILE = "compile"
46
+ QUERY = "query"
47
+ CAPTURE = "capture"
48
+ ORGANIZE = "organize"
49
+ GENERIC = "generic"
50
+
51
+
52
+ class AgentLLMConfig(BaseModel):
53
+ """Per-agent LLM model and generation parameters."""
54
+
55
+ model_config = ConfigDict(extra="forbid")
56
+
57
+ model: str | None = Field(default=None, description="Model identifier. None = vault default.")
58
+ temperature: float = Field(default=0.3, ge=0.0, le=2.0)
59
+ max_tokens: int = Field(default=4096, ge=1)
60
+
61
+
62
+ class AgentPromptConfig(BaseModel):
63
+ """System prompt for the agent. Taken as-is from TOML."""
64
+
65
+ model_config = ConfigDict(extra="forbid")
66
+
67
+ system: str = Field(description="System prompt text. Written as-is; default language is English.")
68
+
69
+
70
+ class AgentToolsConfig(BaseModel):
71
+ """Tool access configuration for the agent."""
72
+
73
+ model_config = ConfigDict(extra="forbid")
74
+
75
+ enabled: list[str] | None = Field(
76
+ default=None,
77
+ description="Tool names the agent may call. None = all available tools.",
78
+ )
79
+
80
+
81
+ class AgentBehaviorConfig(BaseModel):
82
+ """Behavioral limits for the conversational loop."""
83
+
84
+ model_config = ConfigDict(extra="forbid")
85
+
86
+ max_turns: int = Field(default=10, ge=1, description="Maximum LLM round-trips per prompt.")
87
+ stream_progress: bool = Field(default=True, description="Forward tool progress as session/update chunks.")
88
+
89
+
90
+ class AgentDefinition(BaseModel):
91
+ """A single TOML-defined conversational agent.
92
+
93
+ Loaded from a TOML file via :meth:`from_toml` or constructed directly.
94
+ Used by :class:`~kompend.acp.conversational.ConversationalAgent` and
95
+ :class:`~kompend.acp.registry.AgentRegistry`.
96
+ """
97
+
98
+ model_config = ConfigDict(extra="forbid")
99
+
100
+ name: str = Field(description="Unique agent name (matches filename without .toml).")
101
+ description: str = Field(description="Human-readable description shown in `kompend agents list`.")
102
+ task: AgentTask = Field(description="Task category for selection.")
103
+ llm: AgentLLMConfig = Field(default_factory=AgentLLMConfig)
104
+ prompt: AgentPromptConfig
105
+ tools: AgentToolsConfig = Field(default_factory=AgentToolsConfig)
106
+ behavior: AgentBehaviorConfig = Field(default_factory=AgentBehaviorConfig)
107
+
108
+ @classmethod
109
+ def from_toml(cls, path: str | Path) -> AgentDefinition:
110
+ """Load an agent definition from a TOML file.
111
+
112
+ Args:
113
+ path: Path to the TOML file.
114
+
115
+ Returns:
116
+ Parsed and validated :class:`AgentDefinition`.
117
+
118
+ Raises:
119
+ FileNotFoundError: If *path* does not exist.
120
+ ValidationError: If the TOML content doesn't match the schema.
121
+ """
122
+ path = Path(path)
123
+ with path.open("rb") as f:
124
+ data: dict[str, Any] = tomllib.load(f)
125
+ return cls.model_validate(data)
126
+
127
+ @classmethod
128
+ def from_dict(cls, data: dict[str, Any]) -> AgentDefinition:
129
+ """Construct from a pre-parsed dict (e.g. from config.toml inline agent)."""
130
+ return cls.model_validate(data)
@@ -0,0 +1,65 @@
1
+ """Harness adapter — builds a PydanticAI Agent for ACP serving.
2
+
3
+ Provides :func:`build_kompend_agent` (a generic agent with all kompend tools) and
4
+ :func:`kompend_session_config` (a per-session factory that roots tools at the
5
+ client's workspace and resolves the active agent definition).
6
+
7
+ Used by :mod:`kompend.cli.cmds.agent` to serve kompend over ACP via
8
+ ``run_acp_stdio_sync``.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from pydantic_ai import Agent
14
+ from pydantic_ai_harness.experimental.acp import AcpSession, AcpSessionConfig
15
+
16
+ from kompend.acp.definitions import AgentTask
17
+ from kompend.acp.registry import AgentRegistry
18
+ from kompend.acp.tools import build_toolset
19
+ from kompend.logging import get_logger
20
+
21
+ logger = get_logger(__name__)
22
+
23
+
24
+ def build_kompend_agent() -> Agent[None, str]:
25
+ """Build a generic PydanticAI Agent with a placeholder model.
26
+
27
+ The actual model is resolved per-session via the config or
28
+ ``providers/set`` override. The agent uses a minimal system prompt —
29
+ the per-session ``session_config`` factory overrides instructions
30
+ based on the active agent definition.
31
+ """
32
+ return Agent(
33
+ "noop",
34
+ instructions="You are a kompend knowledge base assistant.",
35
+ name="acp-session-agent",
36
+ )
37
+
38
+
39
+ def kompend_session_config(session: AcpSession) -> AcpSessionConfig[None]:
40
+ """Per-session factory for ``run_acp_stdio_sync(session_config=...)``.
41
+
42
+ Resolves the active agent definition for the session's workspace and
43
+ returns an ``AcpSessionConfig`` with the appropriate toolset and
44
+ instructions.
45
+
46
+ Args:
47
+ session: The :class:`AcpSession` from the harness (has ``cwd``,
48
+ ``mcp_servers``, ``client_capabilities``).
49
+
50
+ Returns:
51
+ An ``AcpSessionConfig`` with deps=None and the resolved toolset.
52
+ """
53
+ cwd = session.cwd
54
+ registry = AgentRegistry(base_dir=cwd)
55
+ definition = registry.active_for(AgentTask.GENERIC, {})
56
+
57
+ toolset = build_toolset(
58
+ base_dir=cwd,
59
+ enabled=definition.tools.enabled,
60
+ )
61
+
62
+ return AcpSessionConfig(
63
+ deps=None,
64
+ toolsets=[toolset],
65
+ )