pygenius-ai 0.1.1__tar.gz

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 (155) hide show
  1. pygenius_ai-0.1.1/.gitignore +32 -0
  2. pygenius_ai-0.1.1/CHANGELOG.md +139 -0
  3. pygenius_ai-0.1.1/LICENSE +21 -0
  4. pygenius_ai-0.1.1/PKG-INFO +583 -0
  5. pygenius_ai-0.1.1/README.md +536 -0
  6. pygenius_ai-0.1.1/examples/demo_interactive.py +138 -0
  7. pygenius_ai-0.1.1/examples/demo_mock.py +170 -0
  8. pygenius_ai-0.1.1/pyproject.toml +112 -0
  9. pygenius_ai-0.1.1/sandbox/Dockerfile +24 -0
  10. pygenius_ai-0.1.1/src/pygenius/__init__.py +3 -0
  11. pygenius_ai-0.1.1/src/pygenius/agents/__init__.py +1 -0
  12. pygenius_ai-0.1.1/src/pygenius/agents/base.py +86 -0
  13. pygenius_ai-0.1.1/src/pygenius/agents/coder.py +1819 -0
  14. pygenius_ai-0.1.1/src/pygenius/agents/planner.py +533 -0
  15. pygenius_ai-0.1.1/src/pygenius/agents/reviewer.py +507 -0
  16. pygenius_ai-0.1.1/src/pygenius/budget/__init__.py +76 -0
  17. pygenius_ai-0.1.1/src/pygenius/budget/token_budget.py +5 -0
  18. pygenius_ai-0.1.1/src/pygenius/config/__init__.py +5 -0
  19. pygenius_ai-0.1.1/src/pygenius/config/settings.py +108 -0
  20. pygenius_ai-0.1.1/src/pygenius/context/__init__.py +1 -0
  21. pygenius_ai-0.1.1/src/pygenius/context/assembler.py +239 -0
  22. pygenius_ai-0.1.1/src/pygenius/context/dependency.py +214 -0
  23. pygenius_ai-0.1.1/src/pygenius/context/extractor.py +306 -0
  24. pygenius_ai-0.1.1/src/pygenius/events/__init__.py +5 -0
  25. pygenius_ai-0.1.1/src/pygenius/events/event_bus.py +140 -0
  26. pygenius_ai-0.1.1/src/pygenius/interaction/__init__.py +34 -0
  27. pygenius_ai-0.1.1/src/pygenius/interaction/auto.py +59 -0
  28. pygenius_ai-0.1.1/src/pygenius/interaction/base.py +119 -0
  29. pygenius_ai-0.1.1/src/pygenius/interaction/cli_callback.py +180 -0
  30. pygenius_ai-0.1.1/src/pygenius/llm/__init__.py +24 -0
  31. pygenius_ai-0.1.1/src/pygenius/llm/base.py +248 -0
  32. pygenius_ai-0.1.1/src/pygenius/llm/codegen_mock.py +697 -0
  33. pygenius_ai-0.1.1/src/pygenius/llm/mock.py +235 -0
  34. pygenius_ai-0.1.1/src/pygenius/llm/openai_provider.py +357 -0
  35. pygenius_ai-0.1.1/src/pygenius/llm/router.py +795 -0
  36. pygenius_ai-0.1.1/src/pygenius/main.py +1120 -0
  37. pygenius_ai-0.1.1/src/pygenius/mcp/__init__.py +16 -0
  38. pygenius_ai-0.1.1/src/pygenius/mcp/prompts.py +178 -0
  39. pygenius_ai-0.1.1/src/pygenius/mcp/protocol.py +177 -0
  40. pygenius_ai-0.1.1/src/pygenius/mcp/resources.py +253 -0
  41. pygenius_ai-0.1.1/src/pygenius/mcp/server.py +553 -0
  42. pygenius_ai-0.1.1/src/pygenius/mcp/tools.py +295 -0
  43. pygenius_ai-0.1.1/src/pygenius/memory/__init__.py +1 -0
  44. pygenius_ai-0.1.1/src/pygenius/memory/cache.py +6 -0
  45. pygenius_ai-0.1.1/src/pygenius/memory/long_term.py +414 -0
  46. pygenius_ai-0.1.1/src/pygenius/memory/short_term.py +172 -0
  47. pygenius_ai-0.1.1/src/pygenius/memory/vector.py +206 -0
  48. pygenius_ai-0.1.1/src/pygenius/models/__init__.py +1 -0
  49. pygenius_ai-0.1.1/src/pygenius/models/context.py +58 -0
  50. pygenius_ai-0.1.1/src/pygenius/models/messages.py +110 -0
  51. pygenius_ai-0.1.1/src/pygenius/models/tasks.py +223 -0
  52. pygenius_ai-0.1.1/src/pygenius/orchestrator/__init__.py +1 -0
  53. pygenius_ai-0.1.1/src/pygenius/orchestrator/orchestrator.py +1287 -0
  54. pygenius_ai-0.1.1/src/pygenius/orchestrator/parallelism_report.py +396 -0
  55. pygenius_ai-0.1.1/src/pygenius/py.typed +0 -0
  56. pygenius_ai-0.1.1/src/pygenius/sandbox/__init__.py +5 -0
  57. pygenius_ai-0.1.1/src/pygenius/sandbox/docker_sandbox.py +286 -0
  58. pygenius_ai-0.1.1/src/pygenius/tools/__init__.py +1 -0
  59. pygenius_ai-0.1.1/src/pygenius/tools/ast_engine.py +123 -0
  60. pygenius_ai-0.1.1/src/pygenius/tools/command.py +184 -0
  61. pygenius_ai-0.1.1/src/pygenius/tools/file_ops.py +297 -0
  62. pygenius_ai-0.1.1/src/pygenius/tools/git_ops.py +140 -0
  63. pygenius_ai-0.1.1/src/pygenius/tools/linter.py +277 -0
  64. pygenius_ai-0.1.1/src/pygenius/tools/package_manager.py +210 -0
  65. pygenius_ai-0.1.1/src/pygenius/tools/quality_checker.py +363 -0
  66. pygenius_ai-0.1.1/src/pygenius/tools/registry.py +240 -0
  67. pygenius_ai-0.1.1/src/pygenius/tools/security.py +159 -0
  68. pygenius_ai-0.1.1/src/pygenius/tools/tester.py +182 -0
  69. pygenius_ai-0.1.1/src/pygenius/tools/web_ops.py +285 -0
  70. pygenius_ai-0.1.1/tests/conftest.py +111 -0
  71. pygenius_ai-0.1.1/tests/test_agents.py +570 -0
  72. pygenius_ai-0.1.1/tests/test_assembler.py +226 -0
  73. pygenius_ai-0.1.1/tests/test_assembler_comprehensive.py +279 -0
  74. pygenius_ai-0.1.1/tests/test_assembler_edge_cases.py +211 -0
  75. pygenius_ai-0.1.1/tests/test_assembler_remaining.py +108 -0
  76. pygenius_ai-0.1.1/tests/test_ast_engine.py +152 -0
  77. pygenius_ai-0.1.1/tests/test_ast_engine_comprehensive.py +179 -0
  78. pygenius_ai-0.1.1/tests/test_ast_engine_edge_cases.py +61 -0
  79. pygenius_ai-0.1.1/tests/test_base_agent.py +169 -0
  80. pygenius_ai-0.1.1/tests/test_budget.py +67 -0
  81. pygenius_ai-0.1.1/tests/test_cache.py +94 -0
  82. pygenius_ai-0.1.1/tests/test_cli.py +518 -0
  83. pygenius_ai-0.1.1/tests/test_cli_callback.py +170 -0
  84. pygenius_ai-0.1.1/tests/test_cli_callback_interaction.py +158 -0
  85. pygenius_ai-0.1.1/tests/test_codegen_mock_expansion.py +262 -0
  86. pygenius_ai-0.1.1/tests/test_coder.py +562 -0
  87. pygenius_ai-0.1.1/tests/test_coder_actions.py +371 -0
  88. pygenius_ai-0.1.1/tests/test_coder_enhanced.py +330 -0
  89. pygenius_ai-0.1.1/tests/test_coder_parse_edge_cases.py +346 -0
  90. pygenius_ai-0.1.1/tests/test_coder_robustness.py +494 -0
  91. pygenius_ai-0.1.1/tests/test_coder_v6.py +397 -0
  92. pygenius_ai-0.1.1/tests/test_command.py +132 -0
  93. pygenius_ai-0.1.1/tests/test_command_docker_mocked.py +205 -0
  94. pygenius_ai-0.1.1/tests/test_command_edge_cases.py +183 -0
  95. pygenius_ai-0.1.1/tests/test_config.py +72 -0
  96. pygenius_ai-0.1.1/tests/test_context.py +81 -0
  97. pygenius_ai-0.1.1/tests/test_context_comprehensive.py +561 -0
  98. pygenius_ai-0.1.1/tests/test_defense_overwrite.py +394 -0
  99. pygenius_ai-0.1.1/tests/test_dependency.py +101 -0
  100. pygenius_ai-0.1.1/tests/test_dependency_comprehensive.py +330 -0
  101. pygenius_ai-0.1.1/tests/test_docker_sandbox.py +130 -0
  102. pygenius_ai-0.1.1/tests/test_docker_sandbox_mocked.py +417 -0
  103. pygenius_ai-0.1.1/tests/test_event_bus.py +248 -0
  104. pygenius_ai-0.1.1/tests/test_events.py +72 -0
  105. pygenius_ai-0.1.1/tests/test_file_ops_comprehensive.py +119 -0
  106. pygenius_ai-0.1.1/tests/test_git_ops.py +178 -0
  107. pygenius_ai-0.1.1/tests/test_git_ops_safety.py +76 -0
  108. pygenius_ai-0.1.1/tests/test_interaction.py +381 -0
  109. pygenius_ai-0.1.1/tests/test_linter.py +161 -0
  110. pygenius_ai-0.1.1/tests/test_linter_comprehensive.py +351 -0
  111. pygenius_ai-0.1.1/tests/test_linter_edge_cases.py +137 -0
  112. pygenius_ai-0.1.1/tests/test_linter_fallback.py +111 -0
  113. pygenius_ai-0.1.1/tests/test_linter_resolution.py +279 -0
  114. pygenius_ai-0.1.1/tests/test_llm.py +164 -0
  115. pygenius_ai-0.1.1/tests/test_llm_base_helpers.py +81 -0
  116. pygenius_ai-0.1.1/tests/test_llm_mock_extras.py +56 -0
  117. pygenius_ai-0.1.1/tests/test_llm_router.py +1759 -0
  118. pygenius_ai-0.1.1/tests/test_long_term_comprehensive.py +755 -0
  119. pygenius_ai-0.1.1/tests/test_main_helpers.py +542 -0
  120. pygenius_ai-0.1.1/tests/test_main_verbose.py +224 -0
  121. pygenius_ai-0.1.1/tests/test_mcp_e2e.py +300 -0
  122. pygenius_ai-0.1.1/tests/test_mcp_prompts.py +99 -0
  123. pygenius_ai-0.1.1/tests/test_mcp_protocol.py +176 -0
  124. pygenius_ai-0.1.1/tests/test_mcp_resources.py +203 -0
  125. pygenius_ai-0.1.1/tests/test_mcp_server.py +1032 -0
  126. pygenius_ai-0.1.1/tests/test_mcp_tools.py +74 -0
  127. pygenius_ai-0.1.1/tests/test_memory.py +167 -0
  128. pygenius_ai-0.1.1/tests/test_multi_turn_interaction.py +247 -0
  129. pygenius_ai-0.1.1/tests/test_openai_provider.py +548 -0
  130. pygenius_ai-0.1.1/tests/test_openai_provider_extras.py +295 -0
  131. pygenius_ai-0.1.1/tests/test_openai_streaming.py +262 -0
  132. pygenius_ai-0.1.1/tests/test_orchestrator.py +149 -0
  133. pygenius_ai-0.1.1/tests/test_orchestrator_edge_cases.py +1487 -0
  134. pygenius_ai-0.1.1/tests/test_orchestrator_multi_turn.py +218 -0
  135. pygenius_ai-0.1.1/tests/test_orchestrator_parallel.py +620 -0
  136. pygenius_ai-0.1.1/tests/test_package_manager.py +230 -0
  137. pygenius_ai-0.1.1/tests/test_packaging.py +100 -0
  138. pygenius_ai-0.1.1/tests/test_parallelism_report.py +419 -0
  139. pygenius_ai-0.1.1/tests/test_parser_syntax.py +239 -0
  140. pygenius_ai-0.1.1/tests/test_planner_comprehensive.py +652 -0
  141. pygenius_ai-0.1.1/tests/test_planner_orchestrator_v6.py +235 -0
  142. pygenius_ai-0.1.1/tests/test_progress_feedback.py +326 -0
  143. pygenius_ai-0.1.1/tests/test_quality_checker.py +306 -0
  144. pygenius_ai-0.1.1/tests/test_quality_checker_edge_cases.py +133 -0
  145. pygenius_ai-0.1.1/tests/test_registry.py +206 -0
  146. pygenius_ai-0.1.1/tests/test_reviewer.py +641 -0
  147. pygenius_ai-0.1.1/tests/test_reviewer_quality.py +299 -0
  148. pygenius_ai-0.1.1/tests/test_search_replace.py +436 -0
  149. pygenius_ai-0.1.1/tests/test_short_term_comprehensive.py +134 -0
  150. pygenius_ai-0.1.1/tests/test_tester.py +147 -0
  151. pygenius_ai-0.1.1/tests/test_tester_comprehensive.py +213 -0
  152. pygenius_ai-0.1.1/tests/test_tool_calling.py +2732 -0
  153. pygenius_ai-0.1.1/tests/test_tools.py +135 -0
  154. pygenius_ai-0.1.1/tests/test_vector_memory.py +280 -0
  155. pygenius_ai-0.1.1/tests/test_web_ops.py +618 -0
@@ -0,0 +1,32 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+
7
+ # Virtual environments
8
+ .venv/
9
+ venv/
10
+
11
+ # Build artifacts
12
+ dist/
13
+ build/
14
+
15
+ # Test / coverage caches
16
+ .pytest_cache/
17
+ .coverage
18
+ coverage.xml
19
+ htmlcov/
20
+
21
+ # Type check caches
22
+ .mypy_cache/
23
+ .pyright/
24
+
25
+ # Runtime state (generated projects, memory, checkpoints)
26
+ .pygenius/
27
+ .checkpoints/
28
+
29
+ # OS / editor
30
+ .DS_Store
31
+ .idea/
32
+ .vscode/
@@ -0,0 +1,139 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.1] — 2026-09-02
8
+
9
+ ### Added
10
+
11
+ - **Conflict-visualization Markdown report** — `analyze --report PATH`
12
+ renders a self-contained document from the parallelism analysis:
13
+ task inventory (deps / creates / modifies), conflict-safe wave
14
+ layout with per-wave file claims, file-conflict table with
15
+ write-kind classification (C/M) plus conflict matrix, deferral
16
+ cost with direct *and transitive* causes ("dependency T2 was
17
+ deferred to wave 1"), unresolvable tasks, and heuristic
18
+ recommendations (ownership hotspots, create+modify ordering
19
+ hazards, `--parallel` guidance). Pure renderer
20
+ (`orchestrator/parallelism_report.py`), timestamp-injectable for
21
+ deterministic output; `--json` stdout stays a stable schema.
22
+ - **LTM duplicate merging** — `add()` resolves observations in three
23
+ tiers: exact duplicate → confidence-boost merge (+0.1, capped at
24
+ 1.0, tags union, first-writer content); near-duplicate
25
+ (Jaccard ≥ 0.8 or containment ≥ 0.95, punctuation/case
26
+ insensitive) → merge; version-scoped refinement → classic
27
+ deprecate-and-supersede. No more silent overwrites or
28
+ near-duplicate pile-up.
29
+ - **LTM confidence decay** — `decay(half_life_days=30,
30
+ min_confidence=0.1)`: exponential fade measured from last use,
31
+ auto-prune below threshold, human-sourced entries immune.
32
+ `search()` now refreshes `last_used` / `use_count` — retrieval
33
+ keeps memories alive; idle ones fade out.
34
+ - **LTM compaction** — `merge_duplicates()`: one-time cleanup for
35
+ stores created before duplicate merging (transitive chains
36
+ collapse to a single survivor).
37
+
38
+ ## [0.1.0] — 2026-08-31
39
+
40
+ First public release: the full 59-round engineering arc, 1578 tests,
41
+ 99% coverage, E2E score 100/100.
42
+
43
+ ### Core pipeline
44
+
45
+ - **Multi-agent orchestration** — Planner → Coder → Reviewer pipeline
46
+ (`Orchestrator.execute`): task decomposition, ReAct execution with
47
+ tool calling, iterative review, reflection-driven retries.
48
+ - **Planner framework awareness** — requirement analysis tailored to
49
+ FastAPI / CLI / library / data-project archetypes (structure,
50
+ conventions, task ordering).
51
+ - **Reviewer** — static analysis verdicts (ruff/mypy/pyright/pytest),
52
+ reflection capture into long-term memory, fix-task generation.
53
+ - **Layered defense** — lint + type check + tests gate every task;
54
+ failed reviews trigger structured fix loops instead of silent
55
+ acceptance.
56
+
57
+ ### Coder / ReAct engine
58
+
59
+ - **Native tool calling** — OpenAI-style parallel `tool_calls` with
60
+ serial execution, per-call error isolation, "done" short-circuit.
61
+ - **Text ReAct fallback** — Thought/Action/Observation protocol when
62
+ the provider lacks tool-calling support.
63
+ - **Multi-turn message accumulation** — native and text modes keep
64
+ full conversation state across ReAct steps (OpenAI tool-message
65
+ invariants maintained).
66
+ - **Conversation sliding window** — bounded history with
67
+ (assistant, tool*) pair grouping and context-summary annotation.
68
+ - **State persistence** — `save_state` / `load_state` (pydantic
69
+ round-trip) + `resume_from_checkpoint` for crash recovery.
70
+ - **11 coder tools** — file write/read/search_replace, shell,
71
+ web_search, fetch_url (SSRF-guarded), and more.
72
+
73
+ ### Parallel execution
74
+
75
+ - **Dependency-wave analysis** — `ProjectPlan.get_parallel_batches`
76
+ (DAG level decomposition), file-conflict guard
77
+ (`get_file_conflicts`, conflict-free waves), ideal vs
78
+ safe speedup estimates.
79
+ - **Wave-based true parallelism** —
80
+ `Orchestrator.execute_parallel(max_workers)` runs
81
+ dependency-ready, file-disjoint tasks concurrently
82
+ (ThreadPoolExecutor); per-task isolated Coder agents sharing
83
+ orchestrator dependencies.
84
+ - **CLI** — `generate --parallel [-p] [--max-workers N]` and
85
+ `analyze [--json]` (machine-readable dry-run preview).
86
+
87
+ ### MCP server (Model Context Protocol)
88
+
89
+ - **Round 1 — tools**: `pygenius mcp` stdio JSON-RPC 2.0 server
90
+ exposing `plan` / `analyze` / `generate` with JSON Schemas;
91
+ initialize handshake, per-layer error isolation, tool crashes
92
+ never kill the server.
93
+ - **Round 2 — resources + prompts**: read-only project state
94
+ (`pygenius://status|files|checkpoints|memory`) and parameterized
95
+ prompt templates (`generate-project`, `analyze-parallelism`,
96
+ `code-review`).
97
+ - **Round 3 — progress + dynamic tools**: `_meta.progressToken`
98
+ streaming (`notifications/progress`, per-task done/total),
99
+ `register_tool`/`unregister_tool` with
100
+ `notifications/tools/list_changed`, `ping` liveness.
101
+
102
+ ### LLM routing
103
+
104
+ - **Multi-provider router** — strong/balanced/fast tiers,
105
+ complexity classification (keyword-driven, customizable at
106
+ runtime), health reports, fallback chains, route explanation,
107
+ stats, and config persistence.
108
+ - **Providers** — OpenAI (function calling + SSE streaming),
109
+ mock/scripted providers for deterministic offline testing.
110
+ - **CodeGenMock** — framework-aware deterministic generator that
111
+ powers the offline E2E suite.
112
+
113
+ ### Memory & context
114
+
115
+ - **AST-aware context** — symbol extraction, dependency graph.
116
+ - **Long-term memory** — lessons learned with categories,
117
+ confidence, version scoping.
118
+ - **Vector memory** — ChromaDB-backed semantic pattern retrieval
119
+ with keyword fallback, **lazy initialization** (constructs in
120
+ <0.3s; backend starts on first use).
121
+ - **Short-term memory** — per-task error tracking for reflection.
122
+
123
+ ### Budget & safety
124
+
125
+ - **Token budgeting** — per-task and total budgets with
126
+ exhaustion handling.
127
+ - **Sandbox** — Docker-based execution isolation (memory/CPU
128
+ limits) with capability checks.
129
+ - **Observability** — event bus (pub/sub + history replay),
130
+ console/file observers.
131
+
132
+ ### Engineering
133
+
134
+ - 1578 tests passing (full suite ~3.2 min; fast inner loop
135
+ `pytest -m "not e2e"` ≈ 1.5 min) — VectorMemory lazy init cut
136
+ the suite from ~25 min.
137
+ - 99% line coverage; ruff + mypy (strict) clean across 58 files.
138
+ - PEP 561 `py.typed` inline types; console script `pygenius`;
139
+ hatchling sdist + wheel (twine check PASSED).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PyGenius Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.