codenib 0.1.0__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.
- codenib/__init__.py +62 -0
- codenib/__main__.py +7 -0
- codenib/_lazy.py +36 -0
- codenib/_version.py +26 -0
- codenib/agent/__init__.py +159 -0
- codenib/agent/agent_types.py +40 -0
- codenib/agent/boundary.py +129 -0
- codenib/agent/compile.py +219 -0
- codenib/agent/extract_agent.py +101 -0
- codenib/agent/harness.py +326 -0
- codenib/agent/history.py +242 -0
- codenib/agent/lsp_graph.py +878 -0
- codenib/agent/lsp_provider.py +484 -0
- codenib/agent/rerank_agent.py +419 -0
- codenib/agent/resource_guard.py +90 -0
- codenib/agent/route_context.py +391 -0
- codenib/agent/runner.py +2005 -0
- codenib/agent/runtime/__init__.py +16 -0
- codenib/agent/runtime/context.py +189 -0
- codenib/agent/runtime/trace.py +101 -0
- codenib/agent/skills/__init__.py +25 -0
- codenib/agent/skills/_graphnav.py +235 -0
- codenib/agent/skills/bm25_search/__init__.py +0 -0
- codenib/agent/skills/bm25_search/config.yaml +63 -0
- codenib/agent/skills/bm25_search/executor.py +80 -0
- codenib/agent/skills/bm25_search/skill.md +47 -0
- codenib/agent/skills/code_to_query/__init__.py +0 -0
- codenib/agent/skills/code_to_query/config.yaml +38 -0
- codenib/agent/skills/code_to_query/executor.py +69 -0
- codenib/agent/skills/code_to_query/skill.md +7 -0
- codenib/agent/skills/codenib_context/__init__.py +0 -0
- codenib/agent/skills/codenib_context/config.yaml +44 -0
- codenib/agent/skills/codenib_context/executor.py +184 -0
- codenib/agent/skills/codenib_context/skill.md +21 -0
- codenib/agent/skills/context.py +107 -0
- codenib/agent/skills/core.py +153 -0
- codenib/agent/skills/crossencoder_rerank/__init__.py +3 -0
- codenib/agent/skills/crossencoder_rerank/config.yaml +41 -0
- codenib/agent/skills/crossencoder_rerank/executor.py +62 -0
- codenib/agent/skills/crossencoder_rerank/skill.md +7 -0
- codenib/agent/skills/embedding_search/__init__.py +0 -0
- codenib/agent/skills/embedding_search/config.yaml +53 -0
- codenib/agent/skills/embedding_search/executor.py +57 -0
- codenib/agent/skills/embedding_search/skill.md +47 -0
- codenib/agent/skills/find_callees/__init__.py +0 -0
- codenib/agent/skills/find_callees/config.yaml +22 -0
- codenib/agent/skills/find_callees/executor.py +23 -0
- codenib/agent/skills/find_callees/skill.md +11 -0
- codenib/agent/skills/find_callers/__init__.py +0 -0
- codenib/agent/skills/find_callers/config.yaml +22 -0
- codenib/agent/skills/find_callers/executor.py +23 -0
- codenib/agent/skills/find_callers/skill.md +11 -0
- codenib/agent/skills/hybrid_search/__init__.py +0 -0
- codenib/agent/skills/hybrid_search/config.yaml +38 -0
- codenib/agent/skills/hybrid_search/executor.py +132 -0
- codenib/agent/skills/hybrid_search/skill.md +53 -0
- codenib/agent/skills/llm_rerank/__init__.py +0 -0
- codenib/agent/skills/llm_rerank/config.yaml +33 -0
- codenib/agent/skills/llm_rerank/executor.py +37 -0
- codenib/agent/skills/llm_rerank/skill.md +7 -0
- codenib/agent/skills/loader.py +240 -0
- codenib/agent/skills/lsp_definition/config.yaml +35 -0
- codenib/agent/skills/lsp_definition/executor.py +32 -0
- codenib/agent/skills/lsp_definition/skill.md +18 -0
- codenib/agent/skills/lsp_references/config.yaml +40 -0
- codenib/agent/skills/lsp_references/executor.py +34 -0
- codenib/agent/skills/lsp_references/skill.md +17 -0
- codenib/agent/skills/lsp_route/config.yaml +35 -0
- codenib/agent/skills/lsp_route/executor.py +34 -0
- codenib/agent/skills/lsp_route/skill.md +23 -0
- codenib/agent/skills/registry.py +136 -0
- codenib/agent/skills/repository_search/config.yaml +49 -0
- codenib/agent/skills/repository_search/executor.py +512 -0
- codenib/agent/skills/repository_search/skill.md +28 -0
- codenib/agent/skills/trace/__init__.py +0 -0
- codenib/agent/skills/trace/config.yaml +30 -0
- codenib/agent/skills/trace/executor.py +27 -0
- codenib/agent/skills/trace/skill.md +12 -0
- codenib/agent/skills/typecheck.py +302 -0
- codenib/agent/tool_schema.py +158 -0
- codenib/agent/tools/__init__.py +41 -0
- codenib/agent/tools/defaults.py +1045 -0
- codenib/agent/tools/spec.py +103 -0
- codenib/agent/utils.py +149 -0
- codenib/cli.py +1079 -0
- codenib/clients/__init__.py +5 -0
- codenib/clients/claude_agent.py +534 -0
- codenib/clients/codex_agent.py +314 -0
- codenib/code_chunker.py +730 -0
- codenib/code_chunking/__init__.py +113 -0
- codenib/code_chunking/base.py +592 -0
- codenib/code_chunking/cpp_chunker.py +278 -0
- codenib/code_chunking/csharp_chunker.py +210 -0
- codenib/code_chunking/go_chunker.py +213 -0
- codenib/code_chunking/java_chunker.py +188 -0
- codenib/code_chunking/js_chunker.py +251 -0
- codenib/code_chunking/kotlin_chunker.py +253 -0
- codenib/code_chunking/lua_chunker.py +94 -0
- codenib/code_chunking/php_chunker.py +204 -0
- codenib/code_chunking/python_chunker.py +267 -0
- codenib/code_chunking/ruby_chunker.py +198 -0
- codenib/code_chunking/rust_chunker.py +195 -0
- codenib/code_chunking/scala_chunker.py +182 -0
- codenib/code_chunking/swift_chunker.py +182 -0
- codenib/compat_pickle.py +48 -0
- codenib/compiler/__init__.py +93 -0
- codenib/compiler/index_builders.py +868 -0
- codenib/compiler/index_compiler.py +488 -0
- codenib/compiler/manifest.py +221 -0
- codenib/compiler/params.py +126 -0
- codenib/compiler/resources.py +267 -0
- codenib/compiler/skill_context.py +641 -0
- codenib/compiler/snapshot_store.py +311 -0
- codenib/compiler/verification.py +131 -0
- codenib/dataset/__init__.py +21 -0
- codenib/dataset/base.py +78 -0
- codenib/dataset/codenib_base.py +374 -0
- codenib/dataset/codenib_synthesis.py +540 -0
- codenib/dataset/collect/difficulty_classifier.py +511 -0
- codenib/dataset/collect/swebench_sample.py +766 -0
- codenib/dataset/gt_locate.py +831 -0
- codenib/dataset/local_json.py +184 -0
- codenib/dataset/locbench.py +254 -0
- codenib/dataset/swebench.py +344 -0
- codenib/dataset/swebench_multilingual.py +283 -0
- codenib/dataset/synthesize/__init__.py +71 -0
- codenib/dataset/synthesize/_agent.py +125 -0
- codenib/dataset/synthesize/_types.py +146 -0
- codenib/dataset/synthesize/context_loader.py +601 -0
- codenib/dataset/synthesize/query_curator.py +713 -0
- codenib/dataset/synthesize/query_synthesizer.py +546 -0
- codenib/dataset/synthesize/verifier.py +425 -0
- codenib/dataset/synthesize/vocab_guard.py +264 -0
- codenib/dataset/utils.py +380 -0
- codenib/eval/agent_runner/__init__.py +296 -0
- codenib/eval/agent_runner/baseline.py +299 -0
- codenib/eval/agent_runner/batch.py +176 -0
- codenib/eval/agent_runner/contexts.py +135 -0
- codenib/eval/agent_runner/feedback.py +135 -0
- codenib/eval/agent_runner/feedback_summary.py +326 -0
- codenib/eval/agent_runner/format_diagnostics.py +115 -0
- codenib/eval/agent_runner/live_lsp_provider.py +377 -0
- codenib/eval/agent_runner/loc_baseline.py +355 -0
- codenib/eval/agent_runner/lsp_agent_ab.py +577 -0
- codenib/eval/agent_runner/lsp_agent_study.py +408 -0
- codenib/eval/agent_runner/lsp_agent_study_analysis.py +411 -0
- codenib/eval/agent_runner/lsp_agent_study_artifacts.py +413 -0
- codenib/eval/agent_runner/lsp_agent_study_manifest.py +402 -0
- codenib/eval/agent_runner/lsp_agent_study_runner.py +694 -0
- codenib/eval/agent_runner/lsp_baseline.py +251 -0
- codenib/eval/agent_runner/lsp_latency.py +267 -0
- codenib/eval/agent_runner/lsp_provider_cli.py +273 -0
- codenib/eval/agent_runner/lsp_provider_validation.py +594 -0
- codenib/eval/agent_runner/lsp_readiness.py +167 -0
- codenib/eval/agent_runner/lsp_replay_benchmark.py +1072 -0
- codenib/eval/agent_runner/metrics.py +80 -0
- codenib/eval/agent_runner/orchestrator.py +173 -0
- codenib/eval/agent_runner/pareto.py +154 -0
- codenib/eval/agent_runner/prebuilt.py +484 -0
- codenib/eval/agent_runner/preload.py +219 -0
- codenib/eval/agent_runner/promotion.py +172 -0
- codenib/eval/agent_runner/query_sweep.py +432 -0
- codenib/eval/agent_runner/results.py +69 -0
- codenib/eval/agent_runner/scoring.py +134 -0
- codenib/eval/agent_runner/sweep.py +619 -0
- codenib/eval/agent_runner/sweep_config.py +160 -0
- codenib/eval/agent_runner/symbols.py +67 -0
- codenib/eval/agent_runner/trace_summary.py +405 -0
- codenib/eval/agent_runner/verify_expand.py +219 -0
- codenib/eval/artifact_bundle.py +322 -0
- codenib/eval/artifact_integrity.py +332 -0
- codenib/eval/artifact_manifest.py +236 -0
- codenib/eval/experiments/__init__.py +5 -0
- codenib/eval/experiments/lsp_agent_study_policy.py +55 -0
- codenib/eval/loc_agent_runner.py +37 -0
- codenib/eval/reports/__init__.py +5 -0
- codenib/eval/reports/cost_arm_report.py +810 -0
- codenib/eval/retrieval_eval.py +557 -0
- codenib/graph/__init__.py +44 -0
- codenib/graph/backend_alignment.py +184 -0
- codenib/graph/code_graph.py +1218 -0
- codenib/graph/dependency.py +229 -0
- codenib/graph/hierarchy.py +828 -0
- codenib/graph/incremental/__init__.py +15 -0
- codenib/graph/incremental/change_mgr.py +165 -0
- codenib/graph/incremental/graph_patcher.py +139 -0
- codenib/graph/incremental/lsp_client.py +1271 -0
- codenib/graph/incremental/patcher_base.py +1364 -0
- codenib/graph/incremental/patcher_cpp.py +796 -0
- codenib/graph/incremental/patcher_go.py +56 -0
- codenib/graph/incremental/patcher_python.py +43 -0
- codenib/graph/incremental/patcher_rust.py +113 -0
- codenib/graph/incremental/patcher_ts.py +49 -0
- codenib/graph/incremental/subgraph_mgr.py +1028 -0
- codenib/graph/layers.py +325 -0
- codenib/graph/roi_subgraph.py +394 -0
- codenib/graph/setup.py +689 -0
- codenib/graph/traverse_graph.py +237 -0
- codenib/index/__init__.py +42 -0
- codenib/index/embedding/__init__.py +48 -0
- codenib/index/embedding/builders.py +190 -0
- codenib/index/embedding/model_policy.py +62 -0
- codenib/index/embedding/prompt_registry.py +87 -0
- codenib/index/embedding/vector_store.py +1458 -0
- codenib/index/incremental/__init__.py +30 -0
- codenib/index/incremental/chunk_store.py +409 -0
- codenib/index/incremental/embeddings_cache.py +196 -0
- codenib/index/incremental/git_diff.py +221 -0
- codenib/index/incremental/index_updater.py +283 -0
- codenib/index/incremental/state.py +92 -0
- codenib/index/regex_idx/__init__.py +7 -0
- codenib/index/regex_idx/regex_idx.py +150 -0
- codenib/index/rerank/__init__.py +23 -0
- codenib/index/rerank/cross_encoder.py +356 -0
- codenib/index/sparse_idx/__init__.py +9 -0
- codenib/index/sparse_idx/bm25_index.py +724 -0
- codenib/index/trigram/__init__.py +17 -0
- codenib/index/trigram/zoekt_searcher.py +371 -0
- codenib/languages.py +1035 -0
- codenib/llm/__init__.py +33 -0
- codenib/llm/diagnostics.py +170 -0
- codenib/llm/litellm_chat.py +422 -0
- codenib/llm/options.py +139 -0
- codenib/llm/usage.py +182 -0
- codenib/log_utils.py +301 -0
- codenib/ls_index/__init__.py +17 -0
- codenib/ls_index/clangd_decode.py +912 -0
- codenib/ls_index/clangd_indexer.py +1400 -0
- codenib/ls_index/index_quality.py +442 -0
- codenib/ls_index/lsp_graph_decode.py +449 -0
- codenib/ls_index/lsp_indexer.py +246 -0
- codenib/ls_router.py +507 -0
- codenib/mcp/__init__.py +13 -0
- codenib/mcp/__main__.py +9 -0
- codenib/mcp/context.py +211 -0
- codenib/mcp/prompts.py +76 -0
- codenib/mcp/server.py +463 -0
- codenib/mcp/tools/__init__.py +9 -0
- codenib/mcp/tools/dependency.py +56 -0
- codenib/mcp/tools/lsp.py +119 -0
- codenib/mcp/tools/search.py +224 -0
- codenib/model/__init__.py +49 -0
- codenib/model/agentless_pipeline.py +484 -0
- codenib/model/bm25_retrieve_pipeline.py +100 -0
- codenib/model/dense_graph_expand_rerank_pipeline.py +300 -0
- codenib/model/embedding_retrieve_pipeline.py +152 -0
- codenib/model/graph_augmented_rerank_pipeline.py +19 -0
- codenib/model/graph_retrieve_pipeline.py +259 -0
- codenib/model/hybrid_retrieve_pipeline.py +256 -0
- codenib/model/retrieval_planner.py +377 -0
- codenib/model/retrieve_rerank_pipeline.py +1023 -0
- codenib/ops/expand.py +299 -0
- codenib/ops/filter.py +159 -0
- codenib/ops/rerank.py +246 -0
- codenib/ops/retrieve.py +293 -0
- codenib/ops/transform.py +34 -0
- codenib/paths.py +91 -0
- codenib/profiler.py +506 -0
- codenib/repository_filters.py +103 -0
- codenib/repository_summary.py +161 -0
- codenib/scip_interface/__init__.py +120 -0
- codenib/scip_interface/lsp_occurrence_index.py +327 -0
- codenib/scip_interface/rust_analyzer.py +29 -0
- codenib/scip_interface/scip-environment.yml +14 -0
- codenib/scip_interface/scip.proto +890 -0
- codenib/scip_interface/scip_decode_core.py +190 -0
- codenib/scip_interface/scip_decode_csharp.py +143 -0
- codenib/scip_interface/scip_decode_go.py +433 -0
- codenib/scip_interface/scip_decode_java.py +1117 -0
- codenib/scip_interface/scip_decode_php.py +194 -0
- codenib/scip_interface/scip_decode_python.py +400 -0
- codenib/scip_interface/scip_decode_ruby.py +464 -0
- codenib/scip_interface/scip_decode_rust.py +584 -0
- codenib/scip_interface/scip_decode_ts.py +542 -0
- codenib/scip_interface/scip_decode_utils.py +52 -0
- codenib/scip_interface/scip_indexer_base.py +728 -0
- codenib/scip_interface/scip_indexer_csharp.py +166 -0
- codenib/scip_interface/scip_indexer_go.py +164 -0
- codenib/scip_interface/scip_indexer_java.py +201 -0
- codenib/scip_interface/scip_indexer_php.py +548 -0
- codenib/scip_interface/scip_indexer_python.py +500 -0
- codenib/scip_interface/scip_indexer_ruby.py +369 -0
- codenib/scip_interface/scip_indexer_rust.py +183 -0
- codenib/scip_interface/scip_indexer_ts.py +616 -0
- codenib/scip_interface/scip_install.sh +8 -0
- codenib/scip_interface/scip_pb2.py +80 -0
- codenib/search.py +371 -0
- codenib/source_fingerprint.py +198 -0
- codenib/types.py +105 -0
- codenib/utils.py +93 -0
- codenib/web/__init__.py +9 -0
- codenib/web/app.py +467 -0
- codenib/web/codemap.py +753 -0
- codenib/web/commit_window.py +296 -0
- codenib/web/config.py +331 -0
- codenib/web/edge_label.py +332 -0
- codenib/web/frontend/assets/AskBar-Q_2zSw_D.js +31 -0
- codenib/web/frontend/assets/CodeGraph-C5zIOx4j.js +3 -0
- codenib/web/frontend/assets/CodePanel-BE7Wg1wI.js +1 -0
- codenib/web/frontend/assets/Codemap-C5Xm7Go_.js +2 -0
- codenib/web/frontend/assets/GraphView-CBBbxS9a.js +2 -0
- codenib/web/frontend/assets/Header-CUW7gfQl.js +1 -0
- codenib/web/frontend/assets/HighlightedBlock-H7FGwbAI.js +1 -0
- codenib/web/frontend/assets/HighlightedCode-CTRFPFV9.js +2 -0
- codenib/web/frontend/assets/Mermaid-NhydXLyh.js +303 -0
- codenib/web/frontend/assets/api-DMyba6Hn.js +1 -0
- codenib/web/frontend/assets/arc-Cj6TUG7b.js +1 -0
- codenib/web/frontend/assets/architectureDiagram-3BPJPVTR-BXC7SbpZ.js +36 -0
- codenib/web/frontend/assets/blockDiagram-GPEHLZMM-BYhhgH_O.js +132 -0
- codenib/web/frontend/assets/c4Diagram-AAUBKEIU-BPe9Xb1K.js +10 -0
- codenib/web/frontend/assets/channel-DGptmZnr.js +1 -0
- codenib/web/frontend/assets/chunk-2J33WTMH-mJuoTx1I.js +1 -0
- codenib/web/frontend/assets/chunk-4BX2VUAB-DyIPfnHV.js +1 -0
- codenib/web/frontend/assets/chunk-55IACEB6-C8bSn9Qq.js +1 -0
- codenib/web/frontend/assets/chunk-727SXJPM-CgiBqZFm.js +206 -0
- codenib/web/frontend/assets/chunk-AQP2D5EJ-DOOlLotN.js +231 -0
- codenib/web/frontend/assets/chunk-FMBD7UC4-mf47mSz2.js +15 -0
- codenib/web/frontend/assets/chunk-ND2GUHAM-D6lobpla.js +1 -0
- codenib/web/frontend/assets/chunk-QZHKN3VN-D9a00sWs.js +1 -0
- codenib/web/frontend/assets/classDiagram-4FO5ZUOK-wDtvnBsq.js +1 -0
- codenib/web/frontend/assets/classDiagram-v2-Q7XG4LA2-wDtvnBsq.js +1 -0
- codenib/web/frontend/assets/cose-bilkent-S5V4N54A-JwC1FU9v.js +1 -0
- codenib/web/frontend/assets/cytoscape.esm-CkSuTymj.js +321 -0
- codenib/web/frontend/assets/dagre-BM42HDAG-BTm6Sb-x.js +4 -0
- codenib/web/frontend/assets/defaultLocale-DX6XiGOO.js +1 -0
- codenib/web/frontend/assets/diagram-2AECGRRQ-C7XNwfvk.js +43 -0
- codenib/web/frontend/assets/diagram-5GNKFQAL-DcLriIgZ.js +10 -0
- codenib/web/frontend/assets/diagram-KO2AKTUF-Bo-6Bpfo.js +3 -0
- codenib/web/frontend/assets/diagram-LMA3HP47-M4Nh-qq-.js +24 -0
- codenib/web/frontend/assets/diagram-OG6HWLK6-BUT1QVEf.js +24 -0
- codenib/web/frontend/assets/erDiagram-TEJ5UH35-DViEMoeP.js +85 -0
- codenib/web/frontend/assets/flowDiagram-I6XJVG4X-DjBB1gSM.js +162 -0
- codenib/web/frontend/assets/ganttDiagram-6RSMTGT7-Drhb89TN.js +292 -0
- codenib/web/frontend/assets/gitGraphDiagram-PVQCEYII-CwqblmoY.js +106 -0
- codenib/web/frontend/assets/graph--OzhPTMs.js +1 -0
- codenib/web/frontend/assets/highlight-CDab0zVI.css +1 -0
- codenib/web/frontend/assets/highlight-CnfLc-V2.js +5 -0
- codenib/web/frontend/assets/index-BHP8c3Tq.js +9 -0
- codenib/web/frontend/assets/index-CKJrqu86.css +1 -0
- codenib/web/frontend/assets/infoDiagram-5YYISTIA-BKq62LUG.js +2 -0
- codenib/web/frontend/assets/init-Gi6I4Gst.js +1 -0
- codenib/web/frontend/assets/ishikawaDiagram-YF4QCWOH-DBAgfp9d.js +70 -0
- codenib/web/frontend/assets/journeyDiagram-JHISSGLW-DwHStEV9.js +139 -0
- codenib/web/frontend/assets/kanban-definition-UN3LZRKU-CWPLLTQn.js +89 -0
- codenib/web/frontend/assets/katex-HP8lGamR.js +257 -0
- codenib/web/frontend/assets/layout-SsrduOYp.js +1 -0
- codenib/web/frontend/assets/linear-DNcGZFnN.js +1 -0
- codenib/web/frontend/assets/mindmap-definition-RKZ34NQL-FZHYTpdO.js +96 -0
- codenib/web/frontend/assets/ordinal-Cboi1Yqb.js +1 -0
- codenib/web/frontend/assets/page-Bn-Q8MBy.js +6 -0
- codenib/web/frontend/assets/page-CESv5Ezw.js +2 -0
- codenib/web/frontend/assets/page-CHsElUu2.js +1 -0
- codenib/web/frontend/assets/page-D1WhIRzi.js +1 -0
- codenib/web/frontend/assets/pieDiagram-4H26LBE5-DKlC7xtb.js +30 -0
- codenib/web/frontend/assets/quadrantDiagram-W4KKPZXB-DldkGUZS.js +7 -0
- codenib/web/frontend/assets/requirementDiagram-4Y6WPE33-Dndb6w-j.js +84 -0
- codenib/web/frontend/assets/sankeyDiagram-5OEKKPKP-B2ewtJAC.js +40 -0
- codenib/web/frontend/assets/sequenceDiagram-3UESZ5HK-2N2KbYFt.js +162 -0
- codenib/web/frontend/assets/stateDiagram-AJRCARHV-CLwUuVlz.js +1 -0
- codenib/web/frontend/assets/stateDiagram-v2-BHNVJYJU-IiZdW_Og.js +1 -0
- codenib/web/frontend/assets/timeline-definition-PNZ67QCA-D_IdllIp.js +120 -0
- codenib/web/frontend/assets/vennDiagram-CIIHVFJN-CSU7pI9M.js +34 -0
- codenib/web/frontend/assets/wardley-L42UT6IY-Bv1Eg1Al.js +161 -0
- codenib/web/frontend/assets/wardleyDiagram-YWT4CUSO-Di3bYwLm.js +78 -0
- codenib/web/frontend/assets/xychartDiagram-2RQKCTM6-CPHWEBiN.js +7 -0
- codenib/web/frontend/codenib-icon.svg +34 -0
- codenib/web/frontend/index.html +29 -0
- codenib/web/frontend/runtime-config.js +1 -0
- codenib/web/launcher.py +252 -0
- codenib/web/local.py +196 -0
- codenib/web/repo_registry.py +561 -0
- codenib/web/schemas.py +329 -0
- codenib/web/static_server.py +213 -0
- codenib/wiki/__init__.py +15 -0
- codenib/wiki/agent_wiki.py +4665 -0
- codenib/wiki/builder.py +849 -0
- codenib/wiki/evidence.py +905 -0
- codenib/wiki/narrator.py +258 -0
- codenib/wiki/outline.py +1432 -0
- codenib/wiki/quality.py +932 -0
- codenib-0.1.0.dist-info/METADATA +293 -0
- codenib-0.1.0.dist-info/RECORD +386 -0
- codenib-0.1.0.dist-info/WHEEL +5 -0
- codenib-0.1.0.dist-info/entry_points.txt +13 -0
- codenib-0.1.0.dist-info/licenses/LICENSE +201 -0
- codenib-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2025-2026 CodeNib Contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
"""Shared agent runner for the query synthesis pipeline."""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
import json
|
|
11
|
+
import re
|
|
12
|
+
from typing import List, Optional
|
|
13
|
+
|
|
14
|
+
from claude_agent_sdk import ClaudeAgentOptions, query
|
|
15
|
+
|
|
16
|
+
from codenib.log_utils import get_logger
|
|
17
|
+
|
|
18
|
+
logger = get_logger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class AgentRunner:
|
|
22
|
+
"""Thin wrapper around the Claude Agent SDK for running LLM calls.
|
|
23
|
+
|
|
24
|
+
Each synthesis module (ContextLoader, QueryCurator, Verifier) gets its
|
|
25
|
+
own ``AgentRunner`` instance, potentially with different ``allowed_tools``
|
|
26
|
+
configurations.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
*,
|
|
32
|
+
model: str = "opus",
|
|
33
|
+
max_turns: int = 10,
|
|
34
|
+
system_prompt: str = "",
|
|
35
|
+
allowed_tools: Optional[List[str]] = None,
|
|
36
|
+
permission_mode: str = "bypassPermissions",
|
|
37
|
+
) -> None:
|
|
38
|
+
self.model = model
|
|
39
|
+
self.max_turns = max_turns
|
|
40
|
+
self.system_prompt = system_prompt
|
|
41
|
+
self.allowed_tools = allowed_tools or []
|
|
42
|
+
self.permission_mode = permission_mode
|
|
43
|
+
|
|
44
|
+
def run(self, prompt: str, *, cwd: Optional[str] = None) -> str:
|
|
45
|
+
"""Synchronous agent call (delegates to async via ``asyncio.run``)."""
|
|
46
|
+
try:
|
|
47
|
+
asyncio.get_running_loop()
|
|
48
|
+
except RuntimeError:
|
|
49
|
+
return asyncio.run(self.run_async(prompt, cwd=cwd))
|
|
50
|
+
raise RuntimeError(
|
|
51
|
+
"Running inside an active event loop. Use run_async instead."
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
async def run_async(self, prompt: str, *, cwd: Optional[str] = None) -> str:
|
|
55
|
+
"""Asynchronous agent call — streams messages from Claude."""
|
|
56
|
+
options = ClaudeAgentOptions(
|
|
57
|
+
max_turns=self.max_turns,
|
|
58
|
+
system_prompt=self.system_prompt,
|
|
59
|
+
allowed_tools=self.allowed_tools,
|
|
60
|
+
permission_mode=self.permission_mode,
|
|
61
|
+
model=self.model,
|
|
62
|
+
cwd=cwd,
|
|
63
|
+
)
|
|
64
|
+
text_chunks: List[str] = []
|
|
65
|
+
final_text: Optional[str] = None
|
|
66
|
+
query_gen = query(prompt=prompt, options=options)
|
|
67
|
+
completed = False
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
async for message in query_gen:
|
|
71
|
+
msg_type = message.__class__.__name__
|
|
72
|
+
logger.debug(f"Agent message type: {msg_type}")
|
|
73
|
+
|
|
74
|
+
if msg_type == "ResultMessage":
|
|
75
|
+
result = getattr(message, "result", None)
|
|
76
|
+
completed = True
|
|
77
|
+
if result and isinstance(result, str):
|
|
78
|
+
final_text = result.strip()
|
|
79
|
+
else:
|
|
80
|
+
final_text = "\n".join(text_chunks).strip()
|
|
81
|
+
continue
|
|
82
|
+
|
|
83
|
+
if msg_type == "ErrorMessage":
|
|
84
|
+
error_msg = getattr(message, "error", "Unknown error")
|
|
85
|
+
logger.error(f"Agent error message: {error_msg}")
|
|
86
|
+
raise RuntimeError(f"Agent returned error: {error_msg}")
|
|
87
|
+
|
|
88
|
+
if msg_type == "AssistantMessage":
|
|
89
|
+
content = getattr(message, "content", None)
|
|
90
|
+
if not content:
|
|
91
|
+
continue
|
|
92
|
+
block_texts: List[str] = []
|
|
93
|
+
for block in content:
|
|
94
|
+
text = getattr(block, "text", None)
|
|
95
|
+
if isinstance(text, str) and text.strip():
|
|
96
|
+
block_texts.append(text.strip())
|
|
97
|
+
if block_texts:
|
|
98
|
+
text_chunks.append("\n".join(block_texts))
|
|
99
|
+
finally:
|
|
100
|
+
if not completed:
|
|
101
|
+
await query_gen.aclose()
|
|
102
|
+
|
|
103
|
+
return final_text if final_text is not None else "\n".join(text_chunks).strip()
|
|
104
|
+
|
|
105
|
+
@staticmethod
|
|
106
|
+
def extract_json(text: str) -> str:
|
|
107
|
+
"""Extract the first valid JSON object from *text*."""
|
|
108
|
+
text = text.strip()
|
|
109
|
+
if not text:
|
|
110
|
+
return text
|
|
111
|
+
|
|
112
|
+
fenced = re.search(r"```(?:json)?\s*(\{[\s\S]*\})\s*```", text)
|
|
113
|
+
if fenced:
|
|
114
|
+
text = fenced.group(1).strip()
|
|
115
|
+
|
|
116
|
+
decoder = json.JSONDecoder()
|
|
117
|
+
for idx, ch in enumerate(text):
|
|
118
|
+
if ch != "{":
|
|
119
|
+
continue
|
|
120
|
+
try:
|
|
121
|
+
_obj, end = decoder.raw_decode(text[idx:])
|
|
122
|
+
return text[idx : idx + end]
|
|
123
|
+
except json.JSONDecodeError:
|
|
124
|
+
continue
|
|
125
|
+
return text
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2025-2026 CodeNib Contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
"""Shared data classes for the query synthesis pipeline."""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Dict, List, Optional, Tuple
|
|
12
|
+
|
|
13
|
+
from pydantic import BaseModel, Field
|
|
14
|
+
|
|
15
|
+
from codenib.dataset.utils import CodeLocation
|
|
16
|
+
from codenib.types import (
|
|
17
|
+
NODE_TYPE_CLASS,
|
|
18
|
+
NODE_TYPE_FUNCTION,
|
|
19
|
+
NODE_TYPE_METHOD,
|
|
20
|
+
NodeInfo,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class QuerySynthesisResult(BaseModel):
|
|
25
|
+
"""Structured output for synthesized queries."""
|
|
26
|
+
|
|
27
|
+
question: str = Field(
|
|
28
|
+
description="Single natural-language question describing the issue."
|
|
29
|
+
)
|
|
30
|
+
focus: Optional[str] = Field(
|
|
31
|
+
default=None,
|
|
32
|
+
description="Optional short phrase highlighting the behavior focus.",
|
|
33
|
+
)
|
|
34
|
+
hints: Optional[List[str]] = Field(
|
|
35
|
+
default=None,
|
|
36
|
+
description="Optional progressive hints that could help locate the code.",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class TargetDiscoveryResult(BaseModel):
|
|
41
|
+
"""Structured output for repository target discovery."""
|
|
42
|
+
|
|
43
|
+
target_files: List[str] = Field(default_factory=list)
|
|
44
|
+
target_symbols: List[str] = Field(default_factory=list)
|
|
45
|
+
target_symbol_nodes: List[NodeInfo] = Field(default_factory=list)
|
|
46
|
+
rationale: Optional[str] = Field(default=None)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class BehavioralSelectionResult(BaseModel):
|
|
50
|
+
"""Structured output for behavior-first synthesis from sampled code blocks."""
|
|
51
|
+
|
|
52
|
+
question: str = Field(description="Natural-language behavioral question.")
|
|
53
|
+
focus: Optional[str] = Field(default=None)
|
|
54
|
+
required_block_ids: List[str] = Field(default_factory=list)
|
|
55
|
+
rationale: Optional[str] = Field(default=None)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@dataclass
|
|
59
|
+
class RepoSnapshot:
|
|
60
|
+
root: Path
|
|
61
|
+
top_level: List[str]
|
|
62
|
+
languages: List[Tuple[str, int]]
|
|
63
|
+
agent_summary: Optional[str] = None
|
|
64
|
+
|
|
65
|
+
def format_summary(self) -> str:
|
|
66
|
+
parts: List[str] = []
|
|
67
|
+
if self.top_level:
|
|
68
|
+
parts.append("Top-level entries: " + ", ".join(self.top_level))
|
|
69
|
+
if self.languages:
|
|
70
|
+
lang_summary = ", ".join(
|
|
71
|
+
f"{ext} ({count})" for ext, count in self.languages
|
|
72
|
+
)
|
|
73
|
+
parts.append(f"File extensions (top): {lang_summary}")
|
|
74
|
+
if self.agent_summary:
|
|
75
|
+
parts.append(f"Agent exploration summary:\n{self.agent_summary}")
|
|
76
|
+
return "\n\n".join(parts)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@dataclass
|
|
80
|
+
class SampledCodeBlock:
|
|
81
|
+
block_id: str
|
|
82
|
+
node_id: int
|
|
83
|
+
node_name: str
|
|
84
|
+
file_path: str
|
|
85
|
+
node_type: str
|
|
86
|
+
start_line: int
|
|
87
|
+
end_line: int
|
|
88
|
+
content: str
|
|
89
|
+
char_count: int
|
|
90
|
+
line_count: int
|
|
91
|
+
|
|
92
|
+
def to_node_info(self, *, include_content: bool = True) -> NodeInfo:
|
|
93
|
+
return NodeInfo(
|
|
94
|
+
node_name=self.node_name,
|
|
95
|
+
type=self.node_type,
|
|
96
|
+
file=self.file_path,
|
|
97
|
+
start_line=self.start_line,
|
|
98
|
+
end_line=self.end_line,
|
|
99
|
+
content=self.content if include_content else None,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
def to_code_location(self) -> CodeLocation:
|
|
103
|
+
symbol_type = None
|
|
104
|
+
if self.node_type in (NODE_TYPE_FUNCTION, NODE_TYPE_METHOD):
|
|
105
|
+
symbol_type = "function"
|
|
106
|
+
elif self.node_type == NODE_TYPE_CLASS:
|
|
107
|
+
symbol_type = "class"
|
|
108
|
+
return CodeLocation(
|
|
109
|
+
file_path=self.file_path,
|
|
110
|
+
symbol_type=symbol_type,
|
|
111
|
+
start_line=self.start_line,
|
|
112
|
+
end_line=self.end_line,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@dataclass
|
|
117
|
+
class BehavioralContext:
|
|
118
|
+
core_block: SampledCodeBlock
|
|
119
|
+
candidate_blocks: List[SampledCodeBlock]
|
|
120
|
+
neighborhood_blocks: List[SampledCodeBlock]
|
|
121
|
+
# {(file_path, leaf_symbol): (start_line, end_line)} over ALL graph symbol
|
|
122
|
+
# nodes (0-based, graph attrs) — used to resolve real line spans for the
|
|
123
|
+
# hint/reasoning path, whose ground truth carries only file:symbol strings.
|
|
124
|
+
# NOT candidate_blocks: those are randomly downsampled to max_candidate_blocks.
|
|
125
|
+
symbol_spans: Dict[Tuple[str, str], Tuple[int, int]] = field(default_factory=dict)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def format_prompt_block(
|
|
129
|
+
block: SampledCodeBlock,
|
|
130
|
+
*,
|
|
131
|
+
is_core: bool = False,
|
|
132
|
+
max_block_chars: int = 1800,
|
|
133
|
+
) -> str:
|
|
134
|
+
"""Format a SampledCodeBlock for inclusion in an LLM prompt."""
|
|
135
|
+
content = block.content
|
|
136
|
+
if len(content) > max_block_chars:
|
|
137
|
+
content = (
|
|
138
|
+
content[:max_block_chars] + "\n# ... truncated for synthesis context ..."
|
|
139
|
+
)
|
|
140
|
+
core_tag = " **CORE**" if is_core else ""
|
|
141
|
+
return (
|
|
142
|
+
f"[{block.block_id}]{core_tag} type={block.node_type} "
|
|
143
|
+
f"lines={block.start_line}-{block.end_line} "
|
|
144
|
+
f"chars={block.char_count}\n"
|
|
145
|
+
f"{content}"
|
|
146
|
+
)
|