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.
- kompend/AGENTS.md +123 -0
- kompend/__init__.py +10 -0
- kompend/__main__.py +8 -0
- kompend/acp/AGENTS.md +65 -0
- kompend/acp/__init__.py +24 -0
- kompend/acp/builtin/capture.toml +24 -0
- kompend/acp/builtin/compile.toml +26 -0
- kompend/acp/builtin/generic.toml +28 -0
- kompend/acp/builtin/query.toml +28 -0
- kompend/acp/definitions.py +130 -0
- kompend/acp/harness_adapter.py +65 -0
- kompend/acp/provider_store.py +164 -0
- kompend/acp/registry.py +151 -0
- kompend/acp/tools.py +171 -0
- kompend/agents/AGENTS.md +152 -0
- kompend/agents/__init__.py +61 -0
- kompend/agents/agentic_harness.py +68 -0
- kompend/agents/base.py +781 -0
- kompend/agents/capture.py +18 -0
- kompend/agents/capture_models.py +36 -0
- kompend/agents/categorize.py +34 -0
- kompend/agents/categorize_models.py +20 -0
- kompend/agents/context_chunk.py +17 -0
- kompend/agents/context_chunk_agentic.py +70 -0
- kompend/agents/context_manager.py +60 -0
- kompend/agents/deps.py +168 -0
- kompend/agents/distill.py +21 -0
- kompend/agents/distill_agentic.py +55 -0
- kompend/agents/doctor.py +53 -0
- kompend/agents/extraction.py +38 -0
- kompend/agents/extraction_reduce.py +25 -0
- kompend/agents/generation.py +130 -0
- kompend/agents/instrument.py +102 -0
- kompend/agents/kompend_model.py +179 -0
- kompend/agents/lint.py +58 -0
- kompend/agents/query.py +71 -0
- kompend/agents/query_agentic.py +56 -0
- kompend/agents/reference_extraction.py +37 -0
- kompend/agents/reference_resolver.py +41 -0
- kompend/agents/remediate.py +81 -0
- kompend/agents/rlm.py +371 -0
- kompend/agents/search.py +54 -0
- kompend/agents/summarizer.py +16 -0
- kompend/agents/summarizer_agentic.py +56 -0
- kompend/agents/types.py +357 -0
- kompend/agents/verification.py +68 -0
- kompend/agents/vlm.py +125 -0
- kompend/agents/wicer.py +54 -0
- kompend/agents/wiki_index.py +67 -0
- kompend/agents/write.py +68 -0
- kompend/capture/AGENTS.md +32 -0
- kompend/capture/__init__.py +5 -0
- kompend/capture/_utils.py +41 -0
- kompend/capture/capture.py +126 -0
- kompend/capture/consolidate.py +175 -0
- kompend/capture/distill.py +329 -0
- kompend/capture/ingest.py +46 -0
- kompend/capture/learn.py +47 -0
- kompend/chunking/AGENTS.md +30 -0
- kompend/chunking/__init__.py +11 -0
- kompend/chunking/contextual.py +202 -0
- kompend/chunking/extractors.py +192 -0
- kompend/chunking/hierarchical.py +325 -0
- kompend/chunking/summarizer.py +262 -0
- kompend/cli/AGENTS.md +243 -0
- kompend/cli/__init__.py +3 -0
- kompend/cli/_ignore.py +132 -0
- kompend/cli/_pipeline_helpers.py +240 -0
- kompend/cli/_post_compile.py +345 -0
- kompend/cli/_progress.py +259 -0
- kompend/cli/_query_helpers.py +435 -0
- kompend/cli/_shared.py +170 -0
- kompend/cli/_sources.py +251 -0
- kompend/cli/_sources_io.py +312 -0
- kompend/cli/app.py +350 -0
- kompend/cli/args/AGENTS.md +168 -0
- kompend/cli/args/__init__.py +213 -0
- kompend/cli/args/common.py +91 -0
- kompend/cli/args/compile.py +98 -0
- kompend/cli/args/config.py +31 -0
- kompend/cli/args/init.py +66 -0
- kompend/cli/args/memory.py +32 -0
- kompend/cli/args/other.py +362 -0
- kompend/cli/args/parse.py +25 -0
- kompend/cli/args/pipeline.py +81 -0
- kompend/cli/args/query.py +94 -0
- kompend/cli/cmds/AGENTS.md +140 -0
- kompend/cli/cmds/__init__.py +55 -0
- kompend/cli/cmds/agent.py +68 -0
- kompend/cli/cmds/agents.py +194 -0
- kompend/cli/cmds/init.py +66 -0
- kompend/cli/cmds/knowledge/__init__.py +1 -0
- kompend/cli/cmds/knowledge/attachments.py +332 -0
- kompend/cli/cmds/knowledge/capture.py +389 -0
- kompend/cli/cmds/knowledge/memory.py +118 -0
- kompend/cli/cmds/knowledge/organize.py +103 -0
- kompend/cli/cmds/knowledge/pack.py +50 -0
- kompend/cli/cmds/knowledge/query.py +291 -0
- kompend/cli/cmds/knowledge/references.py +200 -0
- kompend/cli/cmds/pipeline/__init__.py +1 -0
- kompend/cli/cmds/pipeline/config.py +299 -0
- kompend/cli/cmds/pipeline/pipeline.py +524 -0
- kompend/cli/cmds/pipeline/sources.py +317 -0
- kompend/cli/cmds/pipeline/status.py +139 -0
- kompend/cli/cmds/quality/__init__.py +1 -0
- kompend/cli/cmds/quality/doctor.py +619 -0
- kompend/cli/cmds/quality/doctor_cmd.py +67 -0
- kompend/cli/cmds/quality/lint.py +606 -0
- kompend/cli/cmds/quality/list_parsers_cmd.py +34 -0
- kompend/cli/cmds/quality/log.py +73 -0
- kompend/cli/cmds/quality/provenance_cmd.py +135 -0
- kompend/cli/cmds/quality/review.py +122 -0
- kompend/cli/cmds/quality/status_cmd.py +31 -0
- kompend/cli/cmds/serve.py +55 -0
- kompend/compilation/AGENTS.md +55 -0
- kompend/compilation/__init__.py +11 -0
- kompend/compilation/_checkpoints.py +143 -0
- kompend/compilation/_two_phase_core.py +667 -0
- kompend/compilation/asset_mention_rewriter.py +73 -0
- kompend/compilation/asset_registry.py +127 -0
- kompend/compilation/asset_summarizer.py +49 -0
- kompend/compilation/asset_tools.py +99 -0
- kompend/compilation/base.py +438 -0
- kompend/compilation/concept_broker.py +131 -0
- kompend/compilation/concept_keys.py +143 -0
- kompend/compilation/context_chunk_tools.py +49 -0
- kompend/compilation/distill_tools.py +44 -0
- kompend/compilation/extraction_memory.py +251 -0
- kompend/compilation/flows/__init__.py +23 -0
- kompend/compilation/flows/agentic.py +221 -0
- kompend/compilation/flows/assembly.py +373 -0
- kompend/compilation/flows/extraction.py +533 -0
- kompend/compilation/flows/generation.py +1101 -0
- kompend/compilation/flows/references.py +222 -0
- kompend/compilation/gen_tools.py +65 -0
- kompend/compilation/graph.py +499 -0
- kompend/compilation/overview_tools.py +79 -0
- kompend/compilation/query_tools.py +74 -0
- kompend/compilation/reference_excision.py +98 -0
- kompend/compilation/remediate_tools.py +81 -0
- kompend/compilation/schema.py +149 -0
- kompend/compilation/summarizer_tools.py +46 -0
- kompend/compilation/two_phase.py +355 -0
- kompend/compilation/verification_tools.py +80 -0
- kompend/compilation/wicer.py +474 -0
- kompend/compilation/write_tools.py +50 -0
- kompend/core/AGENTS.md +48 -0
- kompend/core/cache/AGENTS.md +23 -0
- kompend/core/cache/__init__.py +7 -0
- kompend/core/cache/store.py +358 -0
- kompend/core/cache/wiki.py +45 -0
- kompend/core/config/AGENTS.md +160 -0
- kompend/core/config/__init__.py +89 -0
- kompend/core/config/_configs.py +675 -0
- kompend/core/config/_core.py +44 -0
- kompend/core/config/engine/__init__.py +77 -0
- kompend/core/config/engine/_check.py +656 -0
- kompend/core/config/engine/_env.py +80 -0
- kompend/core/config/engine/_loading.py +169 -0
- kompend/core/config/engine/_overlay.py +39 -0
- kompend/core/config/engine/_precedence.py +333 -0
- kompend/core/config/engine/_schema.py +159 -0
- kompend/core/config/generate.py +123 -0
- kompend/core/config/keys.py +150 -0
- kompend/core/config/rumdl.py +114 -0
- kompend/core/env.py +153 -0
- kompend/core/models/AGENTS.md +35 -0
- kompend/core/models/__init__.py +108 -0
- kompend/core/models/assets.py +60 -0
- kompend/core/models/attachments.py +388 -0
- kompend/core/models/chunks.py +115 -0
- kompend/core/models/citations.py +81 -0
- kompend/core/models/elements.py +37 -0
- kompend/core/models/enums.py +261 -0
- kompend/core/models/references.py +163 -0
- kompend/core/models/structured.py +225 -0
- kompend/core/models/trees.py +163 -0
- kompend/core/models/wiki.py +331 -0
- kompend/core/page_builder.py +220 -0
- kompend/core/paths.py +678 -0
- kompend/core/pipeline/AGENTS.md +56 -0
- kompend/core/pipeline/__init__.py +5 -0
- kompend/core/pipeline/assets.py +132 -0
- kompend/core/pipeline/attachments.py +199 -0
- kompend/core/pipeline/config.py +314 -0
- kompend/core/pipeline/entity_types.py +98 -0
- kompend/core/pipeline/export.py +454 -0
- kompend/core/pipeline/ingest.py +346 -0
- kompend/core/pipeline/orchestrator.py +30 -0
- kompend/core/pipeline/parse_cache.py +166 -0
- kompend/core/pipeline/references.py +450 -0
- kompend/core/pipeline/runtime.py +86 -0
- kompend/core/pipeline/stages/__init__.py +7 -0
- kompend/core/pipeline/stages/_compile.py +137 -0
- kompend/core/pipeline/stages/_factory.py +159 -0
- kompend/core/pipeline/stages/_index.py +63 -0
- kompend/core/pipeline/stages/_parse.py +519 -0
- kompend/core/pipeline/stages/_pipeline.py +404 -0
- kompend/core/pipeline/stages/_resolve.py +147 -0
- kompend/core/pipeline/state.py +336 -0
- kompend/core/reporting/AGENTS.md +25 -0
- kompend/core/reporting/__init__.py +5 -0
- kompend/core/reporting/log.py +156 -0
- kompend/core/reporting/runlog.py +160 -0
- kompend/core/resolution/AGENTS.md +23 -0
- kompend/core/resolution/__init__.py +5 -0
- kompend/core/resolution/entity_registry.py +346 -0
- kompend/core/resolution/xref_checker.py +240 -0
- kompend/core/source_metadata.py +161 -0
- kompend/core/store/AGENTS.md +45 -0
- kompend/core/store/__init__.py +32 -0
- kompend/core/store/connection.py +119 -0
- kompend/core/store/legacy.py +52 -0
- kompend/core/store/locate.py +37 -0
- kompend/core/store/schema.py +468 -0
- kompend/core/templates/AGENTS.md +98 -0
- kompend/core/templates/__init__.py +19 -0
- kompend/core/templates/loader.py +519 -0
- kompend/core/text/embedding_text.py +25 -0
- kompend/core/text/encoding.py +159 -0
- kompend/core/text/matching.py +182 -0
- kompend/core/text/rumdl.py +147 -0
- kompend/core/text/slug.py +20 -0
- kompend/core/trust/AGENTS.md +25 -0
- kompend/core/trust/__init__.py +5 -0
- kompend/core/trust/actor.py +39 -0
- kompend/core/utils/AGENTS.md +24 -0
- kompend/core/utils/__init__.py +5 -0
- kompend/core/utils/dicts.py +151 -0
- kompend/core/utils/exceptions.py +16 -0
- kompend/core/utils/time.py +35 -0
- kompend/core/utils/tokens.py +14 -0
- kompend/core/verbosity.py +26 -0
- kompend/lint/AGENTS.md +37 -0
- kompend/lint/__init__.py +35 -0
- kompend/lint/_remediation_gaps.py +272 -0
- kompend/lint/base.py +129 -0
- kompend/lint/flow.py +326 -0
- kompend/lint/gap_analysis.py +335 -0
- kompend/lint/gap_broker.py +49 -0
- kompend/lint/history.py +254 -0
- kompend/lint/llm_rules.py +518 -0
- kompend/lint/remediation.py +90 -0
- kompend/lint/rumdl.toml +22 -0
- kompend/lint/runner.py +278 -0
- kompend/lint/semantic_gaps.py +184 -0
- kompend/lint/structural.py +1335 -0
- kompend/llm/AGENTS.md +92 -0
- kompend/llm/__init__.py +43 -0
- kompend/llm/context_window.py +196 -0
- kompend/llm/debug.py +198 -0
- kompend/llm/format.py +319 -0
- kompend/llm/http_client.py +147 -0
- kompend/llm/models.py +483 -0
- kompend/llm/postprocess.py +432 -0
- kompend/llm/usage.py +132 -0
- kompend/llm/user_providers.py +104 -0
- kompend/logging.py +109 -0
- kompend/mcp/AGENTS.md +36 -0
- kompend/mcp/__init__.py +1 -0
- kompend/mcp/server.py +163 -0
- kompend/mcp/tools/__init__.py +130 -0
- kompend/mcp/tools/_helpers.py +39 -0
- kompend/mcp/tools/attachments.py +223 -0
- kompend/mcp/tools/config.py +161 -0
- kompend/mcp/tools/knowledge.py +388 -0
- kompend/mcp/tools/memory.py +75 -0
- kompend/mcp/tools/packs.py +37 -0
- kompend/mcp/tools/pipeline.py +358 -0
- kompend/mcp/tools/quality.py +549 -0
- kompend/mcp/tools/query.py +149 -0
- kompend/mcp/tools/references.py +134 -0
- kompend/mcp/tools/sources.py +220 -0
- kompend/memory/AGENTS.md +42 -0
- kompend/memory/__init__.py +14 -0
- kompend/memory/lifecycle.py +353 -0
- kompend/memory/store.py +247 -0
- kompend/organize/__init__.py +38 -0
- kompend/organize/categorize.py +351 -0
- kompend/organize/engine.py +204 -0
- kompend/organize/moves.py +258 -0
- kompend/output/AGENTS.md +82 -0
- kompend/output/__init__.py +13 -0
- kompend/output/base.py +54 -0
- kompend/output/bibtex.py +225 -0
- kompend/output/json_writer.py +33 -0
- kompend/output/markdown.py +521 -0
- kompend/output/models.py +68 -0
- kompend/output/pages/__init__.py +21 -0
- kompend/output/pages/index.py +238 -0
- kompend/output/pages/log.py +326 -0
- kompend/output/pages/overview.py +165 -0
- kompend/output/reference_links.py +302 -0
- kompend/output/renderer.py +236 -0
- kompend/output/typst.py +90 -0
- kompend/output/vault.py +870 -0
- kompend/output/wiki_index.py +25 -0
- kompend/packs/AGENTS.md +68 -0
- kompend/packs/__init__.py +15 -0
- kompend/packs/base.py +174 -0
- kompend/packs/builtins/__init__.py +9 -0
- kompend/packs/builtins/academic/__init__.py +5 -0
- kompend/packs/builtins/academic/pack.toml +14 -0
- kompend/packs/builtins/default/pack.toml +16 -0
- kompend/packs/builtins/technical/__init__.py +5 -0
- kompend/packs/builtins/technical/pack.toml +14 -0
- kompend/preprocessing/__init__.py +3 -0
- kompend/preprocessing/dedup/__init__.py +16 -0
- kompend/preprocessing/dedup/base.py +107 -0
- kompend/preprocessing/dedup/embedding_matcher.py +114 -0
- kompend/preprocessing/dedup/minhash_matcher.py +152 -0
- kompend/preprocessing/dedup/orchestrator.py +329 -0
- kompend/preprocessing/dedup/store.py +231 -0
- kompend/preprocessing/downloaders/__init__.py +24 -0
- kompend/preprocessing/downloaders/base.py +15 -0
- kompend/preprocessing/downloaders/crawler.py +209 -0
- kompend/preprocessing/downloaders/duplicate_detector.py +97 -0
- kompend/preprocessing/downloaders/http_downloader.py +236 -0
- kompend/preprocessing/downloaders/url_resolver.py +247 -0
- kompend/preprocessing/parsers/AGENTS.md +133 -0
- kompend/preprocessing/parsers/__init__.py +44 -0
- kompend/preprocessing/parsers/_registry.py +243 -0
- kompend/preprocessing/parsers/base.py +210 -0
- kompend/preprocessing/parsers/markdown.py +102 -0
- kompend/preprocessing/parsers/parsecraft_parser.py +497 -0
- kompend/provenance.py +75 -0
- kompend/rag/AGENTS.md +83 -0
- kompend/rag/__init__.py +53 -0
- kompend/rag/zvec_store.py +904 -0
- kompend/resolution/__init__.py +9 -0
- kompend/resolution/base.py +27 -0
- kompend/resolution/chain.py +43 -0
- kompend/resolution/vlm_enricher.py +203 -0
- kompend/review.py +206 -0
- kompend/scaffolding/__init__.py +23 -0
- kompend/scaffolding/_core.py +425 -0
- kompend/scaffolding/templates/AGENTS.md.j2 +95 -0
- kompend/scaffolding/templates/NOTES.md +22 -0
- kompend/scaffolding/templates/README.md.j2 +40 -0
- kompend/scaffolding/templates/gitignore.j2 +11 -0
- kompend/scaffolding/templates/next_steps.txt.j2 +4 -0
- kompend/search/AGENTS.md +37 -0
- kompend/search/adaptive_retriever.py +173 -0
- kompend/search/budget.py +215 -0
- kompend/search/classifier.py +157 -0
- kompend/search/filters.py +43 -0
- kompend/search/pipeline.py +328 -0
- kompend/search/retriever.py +613 -0
- kompend/templates/capture/capture_system.md.j2 +47 -0
- kompend/templates/capture/distill.md.j2 +43 -0
- kompend/templates/capture/distill_agentic_prompt.md.j2 +15 -0
- kompend/templates/capture/distill_agentic_system.md.j2 +26 -0
- kompend/templates/capture/write_agentic_prompt.md.j2 +1 -0
- kompend/templates/capture/write_agentic_system.md.j2 +23 -0
- kompend/templates/capture/write_prompt.md.j2 +17 -0
- kompend/templates/chunking/contextual_agentic_prompt.md.j2 +8 -0
- kompend/templates/chunking/contextual_agentic_system.md.j2 +17 -0
- kompend/templates/chunking/contextual_context.md.j2 +8 -0
- kompend/templates/chunking/node_summary.md.j2 +26 -0
- kompend/templates/chunking/summarizer_agentic_prompt.md.j2 +10 -0
- kompend/templates/chunking/summarizer_agentic_system.md.j2 +29 -0
- kompend/templates/compilation/extraction_prompt.md.j2 +12 -0
- kompend/templates/compilation/extraction_reduce_prompt.md.j2 +14 -0
- kompend/templates/compilation/extraction_reduce_system.md.j2 +6 -0
- kompend/templates/compilation/extraction_system.md.j2 +24 -0
- kompend/templates/compilation/generation_agentic_prompt.md.j2 +46 -0
- kompend/templates/compilation/generation_agentic_system.md.j2 +42 -0
- kompend/templates/compilation/generation_prompt.md.j2 +62 -0
- kompend/templates/compilation/generation_system.md.j2 +26 -0
- kompend/templates/compilation/reference_extraction_prompt.md.j2 +14 -0
- kompend/templates/compilation/reference_extraction_system.md.j2 +25 -0
- kompend/templates/compilation/reference_resolver_prompt.md.j2 +14 -0
- kompend/templates/compilation/reference_resolver_system.md.j2 +19 -0
- kompend/templates/compilation/wicer_diagnose.md.j2 +12 -0
- kompend/templates/compilation/wicer_evaluate.md.j2 +17 -0
- kompend/templates/compilation/wicer_probe.md.j2 +9 -0
- kompend/templates/lint/clarity-score.md.j2 +15 -0
- kompend/templates/lint/contradiction-detection.md.j2 +38 -0
- kompend/templates/lint/coverage-gap-dedup.md.j2 +27 -0
- kompend/templates/lint/coverage-gap.md.j2 +24 -0
- kompend/templates/lint/factual-consistency.md.j2 +15 -0
- kompend/templates/lint/remediate_agentic_prompt.md.j2 +16 -0
- kompend/templates/lint/remediate_agentic_system.md.j2 +30 -0
- kompend/templates/lint/remediate_concept.md.j2 +46 -0
- kompend/templates/lint/verify_agentic_prompt.md.j2 +2 -0
- kompend/templates/lint/verify_agentic_system.md.j2 +20 -0
- kompend/templates/memory/system_context.md.j2 +9 -0
- kompend/templates/organize/categorize_prompt.md.j2 +14 -0
- kompend/templates/organize/categorize_system.md.j2 +48 -0
- kompend/templates/output/synthesize.md.j2 +16 -0
- kompend/templates/output/synthesize_agentic_prompt.md.j2 +9 -0
- kompend/templates/output/synthesize_agentic_system.md.j2 +23 -0
- kompend/templates/query/synthesize_system.md.j2 +42 -0
- kompend/templates/search/crag_grade.md.j2 +10 -0
- kompend/templates/search/expand_query.md.j2 +26 -0
- kompend/templates/search/hyde_generate.md.j2 +5 -0
- kompend/templates/search/query_agentic_prompt.md.j2 +25 -0
- kompend/templates/search/query_agentic_system.md.j2 +25 -0
- kompend/templates/verification/verify_claim.md.j2 +21 -0
- kompend/templates/verification/verify_system.md.j2 +7 -0
- kompend/trust.py +206 -0
- kompend/types.py +77 -0
- kompend/verification.py +231 -0
- kompend/web/_view_helpers.py +60 -0
- kompend/web/routes_api.py +38 -0
- kompend/web/routes_pages.py +420 -0
- kompend/web/server.py +27 -0
- kompend-2026.10.4.dist-info/METADATA +225 -0
- kompend-2026.10.4.dist-info/RECORD +412 -0
- kompend-2026.10.4.dist-info/WHEEL +4 -0
- kompend-2026.10.4.dist-info/entry_points.txt +2 -0
- 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
kompend/__main__.py
ADDED
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.
|
kompend/acp/__init__.py
ADDED
|
@@ -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
|
+
)
|