k-cli-for-devs 1.0.3__tar.gz → 1.0.4__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 (146) hide show
  1. {k_cli_for_devs-1.0.3/k_cli_for_devs.egg-info → k_cli_for_devs-1.0.4}/PKG-INFO +75 -3
  2. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/README.md +74 -2
  3. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/autonomous_agent.py +49 -6
  4. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/cli.py +242 -0
  5. k_cli_for_devs-1.0.4/k_cli/core/memory.py +97 -0
  6. k_cli_for_devs-1.0.4/k_cli/git/checkpoint.py +217 -0
  7. k_cli_for_devs-1.0.4/k_cli/tools/benchmark_harness.py +230 -0
  8. k_cli_for_devs-1.0.4/k_cli/tools/cicd_healer.py +129 -0
  9. k_cli_for_devs-1.0.4/k_cli/tools/sentinel.py +172 -0
  10. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4/k_cli_for_devs.egg-info}/PKG-INFO +75 -3
  11. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli_for_devs.egg-info/SOURCES.txt +6 -0
  12. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/pyproject.toml +1 -1
  13. k_cli_for_devs-1.0.4/tests/test_autonomous_killer_features.py +171 -0
  14. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/LICENSE +0 -0
  15. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/MANIFEST.in +0 -0
  16. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/__init__.py +0 -0
  17. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/__init__.py +0 -0
  18. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/adversarial_swarm.py +0 -0
  19. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/agent_core.py +0 -0
  20. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/background_daemon.py +0 -0
  21. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/orchestrator.py +0 -0
  22. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/persona.py +0 -0
  23. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/scaffold_engine.py +0 -0
  24. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/strands_agent.py +0 -0
  25. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/agents/subagents.py +0 -0
  26. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/__init__.py +0 -0
  27. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/airgap.py +0 -0
  28. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/credentials.py +0 -0
  29. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/credit_saver.py +0 -0
  30. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/intent_sensor.py +0 -0
  31. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/llm_driver.py +0 -0
  32. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/model_manager.py +0 -0
  33. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/models_hub.py +0 -0
  34. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/prompting.py +0 -0
  35. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/rate_limit_guard.py +0 -0
  36. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/sdk.py +0 -0
  37. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/session.py +0 -0
  38. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/smart_router.py +0 -0
  39. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/storage_manager.py +0 -0
  40. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/core/viewport_engine.py +0 -0
  41. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/demo/demo_runner.py +0 -0
  42. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/git/__init__.py +0 -0
  43. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/git/ai_bisect.py +0 -0
  44. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/git/conflict_resolver.py +0 -0
  45. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/git/git_guard.py +0 -0
  46. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/git/patcher.py +0 -0
  47. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/git/repo_map.py +0 -0
  48. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/git/smart_git.py +0 -0
  49. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/git/verifier.py +0 -0
  50. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/github/__init__.py +0 -0
  51. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/github/dedup_engine.py +0 -0
  52. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/github/github_client.py +0 -0
  53. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/github/github_engine.py +0 -0
  54. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/github/local_hub.py +0 -0
  55. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/github/pr_watcher.py +0 -0
  56. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/github/trending.py +0 -0
  57. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/__init__.py +0 -0
  58. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/audit.py +0 -0
  59. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/chaos_immunity.py +0 -0
  60. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/codebase_qa.py +0 -0
  61. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/command_runner.py +0 -0
  62. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/diagram_generator.py +0 -0
  63. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/doc_retriever.py +0 -0
  64. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/feature.py +0 -0
  65. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/ghost_daemon.py +0 -0
  66. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/incident_triage.py +0 -0
  67. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/mcp_client.py +0 -0
  68. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/repo_gardener.py +0 -0
  69. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/rules.py +0 -0
  70. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/security.py +0 -0
  71. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/security_healer.py +0 -0
  72. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tools/synapse_graph.py +0 -0
  73. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tui/__init__.py +0 -0
  74. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tui/diff_viewer.py +0 -0
  75. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tui/tui.py +0 -0
  76. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tui/tui_animations.py +0 -0
  77. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/tui/tui_app.py +0 -0
  78. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/ui/__init__.py +0 -0
  79. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/ui/simple_repl.py +0 -0
  80. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/web/__init__.py +0 -0
  81. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/web/server.py +0 -0
  82. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/web/static/app.js +0 -0
  83. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/web/static/index.html +0 -0
  84. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/web/static/monitor.html +0 -0
  85. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli/web/static/style.css +0 -0
  86. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli_for_devs.egg-info/dependency_links.txt +0 -0
  87. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli_for_devs.egg-info/entry_points.txt +0 -0
  88. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli_for_devs.egg-info/requires.txt +0 -0
  89. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/k_cli_for_devs.egg-info/top_level.txt +0 -0
  90. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/setup.cfg +0 -0
  91. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_adaptive_smart_router.py +0 -0
  92. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_adversarial_knowledge.py +0 -0
  93. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_adversarial_m6_patcher_git_session.py +0 -0
  94. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_autonomous_agent.py +0 -0
  95. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_challenger_m1_driver_and_mock.py +0 -0
  96. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_challenger_m1_streaming.py +0 -0
  97. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_chaos_immunity.py +0 -0
  98. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_cli.py +0 -0
  99. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_cli_fuzzer_traversal.py +0 -0
  100. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_cli_github_conflict_mcp.py +0 -0
  101. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_codex_hub.py +0 -0
  102. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_command_runner.py +0 -0
  103. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_conflict_resolver.py +0 -0
  104. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_credentials.py +0 -0
  105. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_credit_saver_and_rotator.py +0 -0
  106. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_dedup_engine.py +0 -0
  107. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_devdocs_expansion.py +0 -0
  108. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_diagram_generator.py +0 -0
  109. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_doc_retriever.py +0 -0
  110. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_dynamic_discovery_and_audit.py +0 -0
  111. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_e2e_suite.py +0 -0
  112. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_git_guard.py +0 -0
  113. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_github_client.py +0 -0
  114. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_github_engine.py +0 -0
  115. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_hackathon_bedrock_and_daemon.py +0 -0
  116. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_incident_triage.py +0 -0
  117. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_intent_sensor.py +0 -0
  118. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_k_cli_full_e2e.py +0 -0
  119. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_killer_features.py +0 -0
  120. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_llm_driver.py +0 -0
  121. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_local_hub.py +0 -0
  122. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_mcp_client.py +0 -0
  123. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_model_manager.py +0 -0
  124. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_models_hub.py +0 -0
  125. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_multi_provider_llm_driver.py +0 -0
  126. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_orchestrator.py +0 -0
  127. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_patcher.py +0 -0
  128. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_persona_system.py +0 -0
  129. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_repo_map.py +0 -0
  130. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_rules.py +0 -0
  131. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_sdk.py +0 -0
  132. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_security_healer.py +0 -0
  133. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_session.py +0 -0
  134. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_simple_ui_and_rules.py +0 -0
  135. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_smart_git.py +0 -0
  136. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_storage_manager.py +0 -0
  137. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_strands_agent.py +0 -0
  138. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_subagents.py +0 -0
  139. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_tui.py +0 -0
  140. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_tui_animations.py +0 -0
  141. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_tui_app.py +0 -0
  142. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_tui_app_screens.py +0 -0
  143. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_tui_pilot.py +0 -0
  144. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_verifier.py +0 -0
  145. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_viewport_engine.py +0 -0
  146. {k_cli_for_devs-1.0.3 → k_cli_for_devs-1.0.4}/tests/test_web_ui.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: k-cli-for-devs
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: K-CLI for Devs: Autonomous Self-Healing DevOps & Engineering Agent built with AWS Strands Agents SDK
5
5
  License: MIT License
6
6
 
@@ -89,9 +89,12 @@ pip install k-cli-for-devs
89
89
  - [3. Zero-Trust AST Compiler Verification Guardrails](#3-zero-trust-ast-compiler-verification-guardrails)
90
90
  - [4. Sub-Millisecond Adaptive Intent Sensor & Smart Router](#4-sub-millisecond-adaptive-intent-sensor--smart-router)
91
91
  - [5. Sovereign Air-Gapped Offline Engine](#5-sovereign-air-gapped-offline-engine)
92
+ - [6. Smart Credit Saver ($2 vs $10 Financial Optimization Engine)](#6-smart-credit-saver-2-vs-10-financial-optimization-engine)
93
+ - [7. RateLimitGuard & Multi-Provider Model Auto-Rotation](#7-ratelimitguard--multi-provider-model-auto-rotation)
94
+ - [8. Autonomous Multi-Agent Workstation & Subagent Delegation](#8-autonomous-multi-agent-workstation--subagent-delegation)
92
95
  - [🖥️ 3 Unified Interface Tiers](#️-3-unified-interface-tiers)
93
96
  - [🛡️ The 4 Autonomous Superpowers](#️-the-4-autonomous-superpowers)
94
- - [🌟 The 13 Production-Grade Killer Features](#-the-13-production-grade-killer-features)
97
+ - [🌟 The 15 Production-Grade Killer Features](#-the-15-production-grade-killer-features)
95
98
  - [🏛️ System Architecture Diagram](#️-system-architecture-diagram)
96
99
  - [📦 Installation & Quickstart](#-installation--quickstart)
97
100
  - [💻 Comprehensive CLI Command Catalog](#-comprehensive-cli-command-catalog)
@@ -164,6 +167,9 @@ How does K-CLI compare against leading CLI developer assistants like **Aider**,
164
167
  | **100% Air-Gapped Sovereign Offline Mode** | ✅ **Local SLMs (Bankai) + Offline DevDocs** | ⚠️ Partial (Ollama, no offline docs) | ❌ No (Cloud only) | ❌ No (Cloud only) |
165
168
  | **Multi-Model Adversarial Consensus** | ✅ **Red Team / Blue Team Swarms** | ❌ No (Single model) | ❌ No (Single model) | ❌ No (Single model) |
166
169
  | **Background Auto-Healing Daemon** | ✅ **Autonomous Watcher (`k-cli daemon`)** | ❌ No (Interactive only) | ❌ No (Interactive only) | ❌ No (Cloud webhooks only) |
170
+ | **Smart Credit Saver ($2 vs $10 Benchmark)** | ✅ **Context Pruning & $0.00 AST (85% savings)** | ❌ No (Sends raw context) | ❌ No (Standard pricing) | ❌ No (No optimization) |
171
+ | **RateLimitGuard & Model Auto-Rotation** | ✅ **Circuit Breaker (429 Zero-Downtime)** | ⚠️ Manual fallback | ❌ No (Halts on 429) | ❌ No (Halts on error) |
172
+ | **Autonomous Subagent Spawning** | ✅ **Native Multi-Agent Delegation** | ❌ No (Single agent only) | ⚠️ Partial preview | ❌ No |
167
173
 
168
174
  ---
169
175
 
@@ -204,6 +210,65 @@ For security-sensitive, defense, or offline flight environments, K-CLI operates
204
210
  * Includes an embedded SQLite full-text documentation database (DevDocs offline index) covering Python, FastAPI, Docker, Git, and Rust.
205
211
  * Transmits **zero telemetry, zero metrics, and zero data leakage**.
206
212
 
213
+ ### 6. Smart Credit Saver ($2 vs $10 Financial Optimization Engine)
214
+ Most agentic developer tools rapidly burn $10+ of cloud API credits per session by blindly streaming uncompressed 500-line test outputs, massive directory listings, and repetitive AST context into expensive frontier LLMs.
215
+
216
+ K-CLI’s **Smart Credit Saver** ([`k_cli/core/credit_saver.py`](k_cli/core/credit_saver.py)) slashes token expenditure by **70% to 90%**, enabling complex engineering tasks to execute for **~$1 to $2 instead of $10+**:
217
+ * **Dynamic Context & Output Pruning**: Automatically filters verbose pytest runs, build logs, and file listings down to culprit lines, stack traces, and failure counters, discarding thousands of redundant tokens.
218
+ * **$0.00 Ground-Truth Local AST Verification**: Validates Python syntax natively using the local CPU compiler (`ast.parse` and `py_compile`), completely eliminating costly LLM syntax verification passes.
219
+ * **Sliding Context Window Compaction**: Intelligently condenses intermediate turns while preserving the initial user prompt and ground-truth tool outputs.
220
+ * **Real-Time Financial Telemetry**: Accurately tracks prompt tokens, completion tokens, and dollar savings against an uncompressed frontier baseline, surfaced across the TUI, Web UI, and REST API (e.g. `💰 CreditSaver: Spent $0.18 vs $1.20 baseline (85% saved, 14,200 tokens pruned)`).
221
+
222
+ ### 7. RateLimitGuard & Multi-Provider Model Auto-Rotation
223
+ API rate limits (HTTP 429) and quota exhaustion are the #1 cause of catastrophic failures in autonomous agent loops. K-CLI introduces **RateLimitGuard** ([`k_cli/core/rate_limit_guard.py`](k_cli/core/rate_limit_guard.py)):
224
+ * **Thread-Safe Circuit Breaker**: Automatically catches `429 Too Many Requests`, `RESOURCE_EXHAUSTED`, `RateLimitError`, and `503 Overloaded` exceptions.
225
+ * **Adaptive Jittered Cooldowns**: Enforces an exponential backoff cooldown per provider, preventing repetitive API key throttling.
226
+ * **Zero-Downtime Multi-Provider Auto-Rotation**: When a provider enters cooldown, K-CLI seamlessly and transparently pivots to the next available tier provider with active credentials:
227
+ * **Fast / Tool Execution**: `Gemini 2.5 Flash` ➔ `Claude 3.5 Haiku` ➔ `GPT-4o-mini` ➔ `DeepSeek Chat` ➔ `Groq` ➔ `Local Ollama / Bankai`.
228
+ * **Heavy / Architectural Coding**: `Claude 3.7 Sonnet` ➔ `Gemini 2.5 Pro` ➔ `GPT-4o` ➔ `DeepSeek Coder` ➔ `Bankai-14B` ➔ `Deterministic Fallback`.
229
+ * **Zero User Interruption**: The user never experiences a broken build or stopped workflow due to quota or rate-limit spikes.
230
+
231
+ ### 8. Autonomous Multi-Agent Workstation & Subagent Delegation
232
+ Backed by Google Antigravity & Claude Code architectural principles, K-CLI's [`AutonomousAgent`](k_cli/agents/autonomous_agent.py) executes multi-file projects from **just one single command**:
233
+ * **Autonomous Local Tool ReAct Loop**: Invokes `list_dir`, `read_workspace_file`, `write_workspace_file`, `edit_workspace_file`, `execute_command`, `inspect_repo_structure`, `verify_code_file`, `triage_and_heal_incident`, and `heal_cicd_pipeline`.
234
+ * **Specialized Subagent Spawning (`spawn_subagent`)**: Dynamically dispatches background subagents with isolated context windows:
235
+ * `researcher`: Explores codebase dependencies, symbol maps, and documentation.
236
+ * `coder`: Synthesizes modular, clean implementations.
237
+ * `tester`: Generates test suites and executes local ground-truth verification.
238
+ * `security_auditor`: Audits for OWASP vulnerabilities and secret leaks.
239
+ * `refactorer`: Performs surgical search/replace refactors.
240
+ * `explorer`: Inspects directory trees and module boundaries.
241
+
242
+ ### 9. Autonomous Time-Travel Checkpoints & Instant Rollback (`k-cli undo`)
243
+ AI coding assistants can make unintended file edits. K-CLI protects developer repositories with **Zero-Risk Autonomous Checkpointing** ([`k_cli/git/checkpoint.py`](k_cli/git/checkpoint.py)):
244
+ * **Pre-Execution Snapshot**: Automatically snapshots modified code files to `.kcli/checkpoints/` before running any autonomous tool or command.
245
+ * **Instant Rollback (`k-cli undo` / `rollback`)**: One-command restoration reverting modified files to their exact pre-agent state.
246
+ * **Non-Destructive Safety**: Never runs destructive `git reset --hard` or alters uncommitted working branches.
247
+ * **Unified Visual Diff (`k-cli diff-last`)**: Computes exact syntax-highlighted diffs between the active workspace and the last safe checkpoint.
248
+
249
+ ### 10. Persistent Self-Learning Project Memory (`KCLI.md` & `ProjectMemoryManager`)
250
+ Most agents forget past architectural rules across sessions. K-CLI implements **Self-Learning Project Memory** ([`k_cli/core/memory.py`](k_cli/core/memory.py)):
251
+ * **Repository-Specific Context (`KCLI.md`)**: Automatically tracks tech stack standards, verification commands, and forbidden patterns.
252
+ * **Autonomous Feedback Ingestion**: Whenever a bug is healed or a test is fixed, K-CLI records the lesson into `KCLI.md` so the mistake is never repeated.
253
+ * **Bounded Prompt Injection**: Automatically injects high-signal project memory directly into the autonomous agent's system prompt while strictly bounding tokens to avoid context bloat.
254
+
255
+ ### 11. Standardized Quantitative Evaluation & Benchmark Scorecard (`k-cli eval`)
256
+ To prove production reliability, K-CLI features a **Standardized 5-Battery Evaluation Harness** ([`k_cli/tools/benchmark_harness.py`](k_cli/tools/benchmark_harness.py)):
257
+ * **100% Ground-Truth AST Verification**: Evaluates compiler syntax healing, multi-language crash triage, AST security scanning, 3-way merge conflicts, and ReAct agent synthesis.
258
+ * **Real-World Cost Audit**: Measures exact token and financial savings ($ spent vs. unoptimized $10 baseline).
259
+ * **Official Markdown Scorecard**: Exports `.kcli/BENCHMARK_SCORECARD.md` with pass rates and runtime latency metrics for hackathon validation.
260
+
261
+ ### 12. Autonomous Docker & CI/CD Pipeline Healer (`k-cli cicd`)
262
+ Broken CI/CD workflows and bloated container layers are automatically diagnosed and resolved ([`k_cli/tools/cicd_healer.py`](k_cli/tools/cicd_healer.py)):
263
+ * **GitHub Actions Modernization**: Upgrades legacy action versions (`checkout@v2/v3` ➔ `v4`, `setup-python@v3/v4` ➔ `v5`, Node 20 runtime) and injects `PYTHONPATH=.` for seamless test execution.
264
+ * **Dockerfile Optimization**: Injects `--no-cache` to Alpine `apk add`, cleans `/var/lib/apt/lists/*` on Debian/Ubuntu, and adds `--no-cache-dir` to container `pip` calls.
265
+
266
+ ### 13. Global Ambient Error Interceptor Sentinel (`k-cli wrap <cmd>`)
267
+ K-CLI's ambient copilot intercepts terminal errors the microsecond they happen ([`k_cli/tools/sentinel.py`](k_cli/tools/sentinel.py)):
268
+ * **Sub-Second Interception (< 0.1s)**: Intercepts shell, pip, python runtime exceptions, and git merge conflict failures.
269
+ * **Instant Auto-Remediation**: Automatically resolves missing dependencies, `--break-system-packages` restrictions, missing Python interpreter paths, and syntax crashes.
270
+ * **Transparent Re-Execution**: Auto-retries the command upon applying the verified fix, ensuring uninterrupted developer flow.
271
+
207
272
  ---
208
273
 
209
274
  ## 🖥️ 3 Unified Interface Tiers
@@ -248,7 +313,7 @@ K-CLI provides 3 purpose-built interfaces tailored to developer workflows:
248
313
 
249
314
  ---
250
315
 
251
- ## 🌟 The 13 Production-Grade Killer Features
316
+ ## 🌟 The 20 Production-Grade Killer Features
252
317
 
253
318
  1. **`k-cli exec` / `cmd`**: Google Antigravity-style host machine shell command execution with environment auto-injection.
254
319
  2. **`k-cli watch`**: Autonomous PR Review & Watcher Daemon that monitors repos, reviews diffs, and auto-merges clean PRs.
@@ -263,6 +328,13 @@ K-CLI provides 3 purpose-built interfaces tailored to developer workflows:
263
328
  11. **`k-cli scaffold`**: Natural Language Full-Stack Scaffolder building complete microservices and APIs from a single prompt.
264
329
  12. **`k-cli strands`**: AWS Strands Autonomous Developer Agent executing multi-step engineering goals.
265
330
  13. **`k-cli immune`**: Autonomous Chaos Immunity Engine probing brittle AST nodes and synthesizing edge-case tests.
331
+ 14. **Smart Credit Saver (`CreditSaver`)**: Dynamic context compaction and zero-cost local AST verification slashing API costs by 70-90% ($1-2 vs $10+).
332
+ 15. **RateLimitGuard & Model Auto-Rotator**: Zero-downtime multi-provider circuit breaker auto-rotating across Gemini, Claude, OpenAI, DeepSeek, and Ollama on HTTP 429 rate limits.
333
+ 16. **Time-Travel Checkpoints (`k-cli undo` / `checkpoints` / `diff-last`)**: Non-destructive workspace snapshots with instant 1-command rollback.
334
+ 17. **Self-Learning Project Memory (`k-cli memory`)**: Persistent `KCLI.md` memory remembering architectural rules and past bug solutions.
335
+ 18. **Standardized Evaluation Benchmark (`k-cli eval` / `benchmark`)**: 5-battery quantitative evaluation measuring 100% AST pass rate and financial savings scorecard.
336
+ 19. **Docker & CI/CD Pipeline Healer (`k-cli cicd`)**: Automated repair of broken GitHub Actions workflows and unoptimized Dockerfiles.
337
+ 20. **Global Ambient Error Interceptor (`k-cli wrap <cmd>` / `sentinel`)**: Sub-second error interceptor fixing pip, python runtime, and git failures on the fly.
266
338
 
267
339
  ---
268
340
 
@@ -33,9 +33,12 @@ pip install k-cli-for-devs
33
33
  - [3. Zero-Trust AST Compiler Verification Guardrails](#3-zero-trust-ast-compiler-verification-guardrails)
34
34
  - [4. Sub-Millisecond Adaptive Intent Sensor & Smart Router](#4-sub-millisecond-adaptive-intent-sensor--smart-router)
35
35
  - [5. Sovereign Air-Gapped Offline Engine](#5-sovereign-air-gapped-offline-engine)
36
+ - [6. Smart Credit Saver ($2 vs $10 Financial Optimization Engine)](#6-smart-credit-saver-2-vs-10-financial-optimization-engine)
37
+ - [7. RateLimitGuard & Multi-Provider Model Auto-Rotation](#7-ratelimitguard--multi-provider-model-auto-rotation)
38
+ - [8. Autonomous Multi-Agent Workstation & Subagent Delegation](#8-autonomous-multi-agent-workstation--subagent-delegation)
36
39
  - [🖥️ 3 Unified Interface Tiers](#️-3-unified-interface-tiers)
37
40
  - [🛡️ The 4 Autonomous Superpowers](#️-the-4-autonomous-superpowers)
38
- - [🌟 The 13 Production-Grade Killer Features](#-the-13-production-grade-killer-features)
41
+ - [🌟 The 15 Production-Grade Killer Features](#-the-15-production-grade-killer-features)
39
42
  - [🏛️ System Architecture Diagram](#️-system-architecture-diagram)
40
43
  - [📦 Installation & Quickstart](#-installation--quickstart)
41
44
  - [💻 Comprehensive CLI Command Catalog](#-comprehensive-cli-command-catalog)
@@ -108,6 +111,9 @@ How does K-CLI compare against leading CLI developer assistants like **Aider**,
108
111
  | **100% Air-Gapped Sovereign Offline Mode** | ✅ **Local SLMs (Bankai) + Offline DevDocs** | ⚠️ Partial (Ollama, no offline docs) | ❌ No (Cloud only) | ❌ No (Cloud only) |
109
112
  | **Multi-Model Adversarial Consensus** | ✅ **Red Team / Blue Team Swarms** | ❌ No (Single model) | ❌ No (Single model) | ❌ No (Single model) |
110
113
  | **Background Auto-Healing Daemon** | ✅ **Autonomous Watcher (`k-cli daemon`)** | ❌ No (Interactive only) | ❌ No (Interactive only) | ❌ No (Cloud webhooks only) |
114
+ | **Smart Credit Saver ($2 vs $10 Benchmark)** | ✅ **Context Pruning & $0.00 AST (85% savings)** | ❌ No (Sends raw context) | ❌ No (Standard pricing) | ❌ No (No optimization) |
115
+ | **RateLimitGuard & Model Auto-Rotation** | ✅ **Circuit Breaker (429 Zero-Downtime)** | ⚠️ Manual fallback | ❌ No (Halts on 429) | ❌ No (Halts on error) |
116
+ | **Autonomous Subagent Spawning** | ✅ **Native Multi-Agent Delegation** | ❌ No (Single agent only) | ⚠️ Partial preview | ❌ No |
111
117
 
112
118
  ---
113
119
 
@@ -148,6 +154,65 @@ For security-sensitive, defense, or offline flight environments, K-CLI operates
148
154
  * Includes an embedded SQLite full-text documentation database (DevDocs offline index) covering Python, FastAPI, Docker, Git, and Rust.
149
155
  * Transmits **zero telemetry, zero metrics, and zero data leakage**.
150
156
 
157
+ ### 6. Smart Credit Saver ($2 vs $10 Financial Optimization Engine)
158
+ Most agentic developer tools rapidly burn $10+ of cloud API credits per session by blindly streaming uncompressed 500-line test outputs, massive directory listings, and repetitive AST context into expensive frontier LLMs.
159
+
160
+ K-CLI’s **Smart Credit Saver** ([`k_cli/core/credit_saver.py`](k_cli/core/credit_saver.py)) slashes token expenditure by **70% to 90%**, enabling complex engineering tasks to execute for **~$1 to $2 instead of $10+**:
161
+ * **Dynamic Context & Output Pruning**: Automatically filters verbose pytest runs, build logs, and file listings down to culprit lines, stack traces, and failure counters, discarding thousands of redundant tokens.
162
+ * **$0.00 Ground-Truth Local AST Verification**: Validates Python syntax natively using the local CPU compiler (`ast.parse` and `py_compile`), completely eliminating costly LLM syntax verification passes.
163
+ * **Sliding Context Window Compaction**: Intelligently condenses intermediate turns while preserving the initial user prompt and ground-truth tool outputs.
164
+ * **Real-Time Financial Telemetry**: Accurately tracks prompt tokens, completion tokens, and dollar savings against an uncompressed frontier baseline, surfaced across the TUI, Web UI, and REST API (e.g. `💰 CreditSaver: Spent $0.18 vs $1.20 baseline (85% saved, 14,200 tokens pruned)`).
165
+
166
+ ### 7. RateLimitGuard & Multi-Provider Model Auto-Rotation
167
+ API rate limits (HTTP 429) and quota exhaustion are the #1 cause of catastrophic failures in autonomous agent loops. K-CLI introduces **RateLimitGuard** ([`k_cli/core/rate_limit_guard.py`](k_cli/core/rate_limit_guard.py)):
168
+ * **Thread-Safe Circuit Breaker**: Automatically catches `429 Too Many Requests`, `RESOURCE_EXHAUSTED`, `RateLimitError`, and `503 Overloaded` exceptions.
169
+ * **Adaptive Jittered Cooldowns**: Enforces an exponential backoff cooldown per provider, preventing repetitive API key throttling.
170
+ * **Zero-Downtime Multi-Provider Auto-Rotation**: When a provider enters cooldown, K-CLI seamlessly and transparently pivots to the next available tier provider with active credentials:
171
+ * **Fast / Tool Execution**: `Gemini 2.5 Flash` ➔ `Claude 3.5 Haiku` ➔ `GPT-4o-mini` ➔ `DeepSeek Chat` ➔ `Groq` ➔ `Local Ollama / Bankai`.
172
+ * **Heavy / Architectural Coding**: `Claude 3.7 Sonnet` ➔ `Gemini 2.5 Pro` ➔ `GPT-4o` ➔ `DeepSeek Coder` ➔ `Bankai-14B` ➔ `Deterministic Fallback`.
173
+ * **Zero User Interruption**: The user never experiences a broken build or stopped workflow due to quota or rate-limit spikes.
174
+
175
+ ### 8. Autonomous Multi-Agent Workstation & Subagent Delegation
176
+ Backed by Google Antigravity & Claude Code architectural principles, K-CLI's [`AutonomousAgent`](k_cli/agents/autonomous_agent.py) executes multi-file projects from **just one single command**:
177
+ * **Autonomous Local Tool ReAct Loop**: Invokes `list_dir`, `read_workspace_file`, `write_workspace_file`, `edit_workspace_file`, `execute_command`, `inspect_repo_structure`, `verify_code_file`, `triage_and_heal_incident`, and `heal_cicd_pipeline`.
178
+ * **Specialized Subagent Spawning (`spawn_subagent`)**: Dynamically dispatches background subagents with isolated context windows:
179
+ * `researcher`: Explores codebase dependencies, symbol maps, and documentation.
180
+ * `coder`: Synthesizes modular, clean implementations.
181
+ * `tester`: Generates test suites and executes local ground-truth verification.
182
+ * `security_auditor`: Audits for OWASP vulnerabilities and secret leaks.
183
+ * `refactorer`: Performs surgical search/replace refactors.
184
+ * `explorer`: Inspects directory trees and module boundaries.
185
+
186
+ ### 9. Autonomous Time-Travel Checkpoints & Instant Rollback (`k-cli undo`)
187
+ AI coding assistants can make unintended file edits. K-CLI protects developer repositories with **Zero-Risk Autonomous Checkpointing** ([`k_cli/git/checkpoint.py`](k_cli/git/checkpoint.py)):
188
+ * **Pre-Execution Snapshot**: Automatically snapshots modified code files to `.kcli/checkpoints/` before running any autonomous tool or command.
189
+ * **Instant Rollback (`k-cli undo` / `rollback`)**: One-command restoration reverting modified files to their exact pre-agent state.
190
+ * **Non-Destructive Safety**: Never runs destructive `git reset --hard` or alters uncommitted working branches.
191
+ * **Unified Visual Diff (`k-cli diff-last`)**: Computes exact syntax-highlighted diffs between the active workspace and the last safe checkpoint.
192
+
193
+ ### 10. Persistent Self-Learning Project Memory (`KCLI.md` & `ProjectMemoryManager`)
194
+ Most agents forget past architectural rules across sessions. K-CLI implements **Self-Learning Project Memory** ([`k_cli/core/memory.py`](k_cli/core/memory.py)):
195
+ * **Repository-Specific Context (`KCLI.md`)**: Automatically tracks tech stack standards, verification commands, and forbidden patterns.
196
+ * **Autonomous Feedback Ingestion**: Whenever a bug is healed or a test is fixed, K-CLI records the lesson into `KCLI.md` so the mistake is never repeated.
197
+ * **Bounded Prompt Injection**: Automatically injects high-signal project memory directly into the autonomous agent's system prompt while strictly bounding tokens to avoid context bloat.
198
+
199
+ ### 11. Standardized Quantitative Evaluation & Benchmark Scorecard (`k-cli eval`)
200
+ To prove production reliability, K-CLI features a **Standardized 5-Battery Evaluation Harness** ([`k_cli/tools/benchmark_harness.py`](k_cli/tools/benchmark_harness.py)):
201
+ * **100% Ground-Truth AST Verification**: Evaluates compiler syntax healing, multi-language crash triage, AST security scanning, 3-way merge conflicts, and ReAct agent synthesis.
202
+ * **Real-World Cost Audit**: Measures exact token and financial savings ($ spent vs. unoptimized $10 baseline).
203
+ * **Official Markdown Scorecard**: Exports `.kcli/BENCHMARK_SCORECARD.md` with pass rates and runtime latency metrics for hackathon validation.
204
+
205
+ ### 12. Autonomous Docker & CI/CD Pipeline Healer (`k-cli cicd`)
206
+ Broken CI/CD workflows and bloated container layers are automatically diagnosed and resolved ([`k_cli/tools/cicd_healer.py`](k_cli/tools/cicd_healer.py)):
207
+ * **GitHub Actions Modernization**: Upgrades legacy action versions (`checkout@v2/v3` ➔ `v4`, `setup-python@v3/v4` ➔ `v5`, Node 20 runtime) and injects `PYTHONPATH=.` for seamless test execution.
208
+ * **Dockerfile Optimization**: Injects `--no-cache` to Alpine `apk add`, cleans `/var/lib/apt/lists/*` on Debian/Ubuntu, and adds `--no-cache-dir` to container `pip` calls.
209
+
210
+ ### 13. Global Ambient Error Interceptor Sentinel (`k-cli wrap <cmd>`)
211
+ K-CLI's ambient copilot intercepts terminal errors the microsecond they happen ([`k_cli/tools/sentinel.py`](k_cli/tools/sentinel.py)):
212
+ * **Sub-Second Interception (< 0.1s)**: Intercepts shell, pip, python runtime exceptions, and git merge conflict failures.
213
+ * **Instant Auto-Remediation**: Automatically resolves missing dependencies, `--break-system-packages` restrictions, missing Python interpreter paths, and syntax crashes.
214
+ * **Transparent Re-Execution**: Auto-retries the command upon applying the verified fix, ensuring uninterrupted developer flow.
215
+
151
216
  ---
152
217
 
153
218
  ## 🖥️ 3 Unified Interface Tiers
@@ -192,7 +257,7 @@ K-CLI provides 3 purpose-built interfaces tailored to developer workflows:
192
257
 
193
258
  ---
194
259
 
195
- ## 🌟 The 13 Production-Grade Killer Features
260
+ ## 🌟 The 20 Production-Grade Killer Features
196
261
 
197
262
  1. **`k-cli exec` / `cmd`**: Google Antigravity-style host machine shell command execution with environment auto-injection.
198
263
  2. **`k-cli watch`**: Autonomous PR Review & Watcher Daemon that monitors repos, reviews diffs, and auto-merges clean PRs.
@@ -207,6 +272,13 @@ K-CLI provides 3 purpose-built interfaces tailored to developer workflows:
207
272
  11. **`k-cli scaffold`**: Natural Language Full-Stack Scaffolder building complete microservices and APIs from a single prompt.
208
273
  12. **`k-cli strands`**: AWS Strands Autonomous Developer Agent executing multi-step engineering goals.
209
274
  13. **`k-cli immune`**: Autonomous Chaos Immunity Engine probing brittle AST nodes and synthesizing edge-case tests.
275
+ 14. **Smart Credit Saver (`CreditSaver`)**: Dynamic context compaction and zero-cost local AST verification slashing API costs by 70-90% ($1-2 vs $10+).
276
+ 15. **RateLimitGuard & Model Auto-Rotator**: Zero-downtime multi-provider circuit breaker auto-rotating across Gemini, Claude, OpenAI, DeepSeek, and Ollama on HTTP 429 rate limits.
277
+ 16. **Time-Travel Checkpoints (`k-cli undo` / `checkpoints` / `diff-last`)**: Non-destructive workspace snapshots with instant 1-command rollback.
278
+ 17. **Self-Learning Project Memory (`k-cli memory`)**: Persistent `KCLI.md` memory remembering architectural rules and past bug solutions.
279
+ 18. **Standardized Evaluation Benchmark (`k-cli eval` / `benchmark`)**: 5-battery quantitative evaluation measuring 100% AST pass rate and financial savings scorecard.
280
+ 19. **Docker & CI/CD Pipeline Healer (`k-cli cicd`)**: Automated repair of broken GitHub Actions workflows and unoptimized Dockerfiles.
281
+ 20. **Global Ambient Error Interceptor (`k-cli wrap <cmd>` / `sentinel`)**: Sub-second error interceptor fixing pip, python runtime, and git failures on the fly.
210
282
 
211
283
  ---
212
284
 
@@ -273,6 +273,19 @@ def tool_spawn_subagent(role: str, task: str) -> str:
273
273
  return f"Error executing subagent '{role}': {e}"
274
274
 
275
275
 
276
+ def tool_heal_cicd_pipeline(file_path: str = ".github/workflows/ci.yml") -> str:
277
+ """Audits and auto-repairs GitHub Actions workflow or Dockerfile."""
278
+ try:
279
+ from k_cli.tools.cicd_healer import global_cicd_healer
280
+ if "docker" in file_path.lower():
281
+ res = global_cicd_healer.audit_and_heal_dockerfile(file_path)
282
+ else:
283
+ res = global_cicd_healer.audit_and_heal_workflow(file_path)
284
+ return f"CI/CD Healer for '{file_path}': Success={res.success}, Issues={res.issues_found}, Fixes={res.fixes_applied}"
285
+ except Exception as e:
286
+ return f"Error healing CI/CD pipeline: {e}"
287
+
288
+
276
289
  # Tool registry map
277
290
  AVAILABLE_TOOLS: Dict[str, Callable[..., str]] = {
278
291
  "list_dir": tool_list_dir,
@@ -285,6 +298,7 @@ AVAILABLE_TOOLS: Dict[str, Callable[..., str]] = {
285
298
  "search_codebase": tool_search_codebase,
286
299
  "triage_and_heal_incident": tool_triage_and_heal_incident,
287
300
  "spawn_subagent": tool_spawn_subagent,
301
+ "heal_cicd_pipeline": tool_heal_cicd_pipeline,
288
302
  }
289
303
 
290
304
 
@@ -306,12 +320,17 @@ def build_agentic_system_prompt(cwd: Optional[str] = None) -> str:
306
320
 
307
321
  top_manifest = ", ".join(top_items[:20]) or "standard project tree"
308
322
 
323
+ # Load persistent project memory if available
324
+ from k_cli.core.memory import global_memory_manager
325
+ memory_context = global_memory_manager.load_memory(max_chars=3000)
326
+ memory_section = f"\n\nPERSISTENT PROJECT MEMORY & ARCHITECTURAL CONVENTIONS:\n{memory_context}" if memory_context else ""
327
+
309
328
  return f"""You are K-CLI, a fully autonomous AI DevOps and software engineering workstation running directly on the developer's Linux machine (comparable to Google Antigravity, Aider, and Claude Code).
310
329
 
311
330
  LOCAL MACHINE ENVIRONMENT:
312
331
  - Working Directory: {cwd_path}
313
332
  - Workspace Root Items: {top_manifest}
314
- - Execution Privilege: Full local machine terminal execution & file system read/write via tools.
333
+ - Execution Privilege: Full local machine terminal execution & file system read/write via tools.{memory_section}
315
334
 
316
335
  CRITICAL OPERATIONAL RULES:
317
336
  1. YOU ARE NOT A CHATBOT. You are an autonomous software engineering agent with REAL tools on this local machine.
@@ -342,17 +361,18 @@ Available Tools:
342
361
  - `search_codebase(query="...", directory=".")`: Search for symbols or text across files.
343
362
  - `triage_and_heal_incident(error_traceback="...")`: Automated crash traceback triage and repair.
344
363
  - `spawn_subagent(role="researcher|coder|tester|security_auditor|refactorer|explorer", task="...")`: Delegates subtasks to specialized background subagents (Google Antigravity & Claude Code architecture).
364
+ - `heal_cicd_pipeline(file_path=".github/workflows/ci.yml")`: Audits and repairs broken GitHub Actions workflows and Dockerfiles.
345
365
 
346
366
  COMMUNICATION & NATURAL LANGUAGE STYLE (MANDATORY):
347
367
  - Talk like an elite senior staff engineer (similar to Claude Code, Aider, and Google Antigravity). Direct, natural, authoritative, concise.
348
368
  - ZERO ROBOTIC PREAMBLES OR CONVERSATIONAL FILLER:
349
- - NEVER output robotic phrases like "Okay, I now have a clear picture of...", "Based on the file structure...", "Based on my analysis...", "Here's why I find it impressive:", "Sure, I'd be happy to help!", "Certainly!", or "In summary...".
350
- - Get straight to the technical substance without stating what you are about to do or narrating your cognitive state.
369
+ - NEVER output robotic phrases like "Okay, I now have a clear picture of...", "Based on the file structure...", "Based on my analysis...", "Here's why I find it impressive:", "Sure, I'd be happy to help!", "Certainly!", or "In summary...".
370
+ - Get straight to the technical substance without stating what you are about to do or narrating your cognitive state.
351
371
  - When reviewing a project or directory:
352
- - Deliver a crisp, natural, high-signal technical evaluation.
353
- - Highlight key architectural layers, modules, testing infrastructure, and technical design decisions using clean bullet points and precise paths.
372
+ - Deliver a crisp, natural, high-signal technical evaluation.
373
+ - Highlight key architectural layers, modules, testing infrastructure, and technical design decisions using clean bullet points and precise paths.
354
374
  - When writing or modifying code:
355
- - Perform the filesystem and compiler operations silently using tools, then state what was accomplished and verified.
375
+ - Perform the filesystem and compiler operations silently using tools, then state what was accomplished and verified.
356
376
 
357
377
  Always take real action. Inspect real files, write real code to disk, and verify before giving your final answer."""
358
378
 
@@ -519,6 +539,17 @@ class AutonomousAgent:
519
539
  system_prompt = build_agentic_system_prompt(self.cwd)
520
540
  steps: List[AgentStep] = []
521
541
  tools_executed: List[str] = []
542
+
543
+ # Automatic Non-Destructive Time-Travel Checkpoint before autonomous operations
544
+ from k_cli.git.checkpoint import global_checkpoint_manager
545
+ try:
546
+ ckpt_id = global_checkpoint_manager.create_checkpoint(
547
+ description=f"Autonomous run: {prompt[:80]}"
548
+ )
549
+ if token_callback:
550
+ token_callback("CHECKPOINT", f"🛡️ [Created Time-Travel Checkpoint '{ckpt_id}']\n")
551
+ except Exception as e:
552
+ logger.warning(f"Failed to create pre-run checkpoint: {e}")
522
553
 
523
554
  # 1. Proactive Reconnaissance:
524
555
  lower_prompt = prompt.lower()
@@ -634,6 +665,18 @@ class AutonomousAgent:
634
665
  completion_tokens=total_completion_tokens,
635
666
  )
636
667
 
668
+ if tools_executed:
669
+ try:
670
+ from k_cli.core.memory import global_memory_manager
671
+ tools_str = ", ".join(sorted(set(tools_executed)))
672
+ clean_task = prompt.strip()[:80]
673
+ global_memory_manager.record_learning(
674
+ lesson=f"Executed task: '{clean_task}' (tools used: {tools_str})",
675
+ category="AutonomousTask",
676
+ )
677
+ except Exception:
678
+ pass
679
+
637
680
  return AutonomousAgentResult(
638
681
  success=True,
639
682
  final_response=final_response,
@@ -17,6 +17,7 @@ import json
17
17
  import os
18
18
  import shlex
19
19
  import sys
20
+ import time
20
21
  from pathlib import Path
21
22
 
22
23
  # Ensure project root is in sys.path for direct CLI script execution
@@ -3241,6 +3242,247 @@ def demo_cmd(
3241
3242
  start_cinematic_demo(speed=speed, act=act)
3242
3243
 
3243
3244
 
3245
+ # =============================================================================
3246
+ # Feature 1: Autonomous Time-Travel Checkpoints & Instant Rollback (`k-cli undo`)
3247
+ # =============================================================================
3248
+ @app.command(name="undo", help="Instantly roll back the workspace to the latest safe checkpoint.")
3249
+ @app.command(name="rollback", help="Alias for undo: revert to previous checkpoint.")
3250
+ def undo_cmd(
3251
+ repo: str = typer.Option(".", "--repo", "-r", help="Repository directory to restore."),
3252
+ ):
3253
+ """Reverts workspace state to the most recent pre-execution checkpoint."""
3254
+ from k_cli.git.checkpoint import CheckpointManager
3255
+ mgr = CheckpointManager(workspace_dir=repo)
3256
+ success, msg = mgr.rollback_last_checkpoint()
3257
+ if success:
3258
+ console.print(Panel(
3259
+ f"[bold green]✔ Time-Travel Rollback Succeeded[/bold green]\n\n{msg}",
3260
+ title="🛡️ K-CLI Checkpoint Rollback",
3261
+ border_style="green",
3262
+ ))
3263
+ else:
3264
+ console.print(Panel(
3265
+ f"[bold red]✘ Rollback Failed[/bold red]\n\n{msg}",
3266
+ title="🛡️ K-CLI Checkpoint Rollback",
3267
+ border_style="red",
3268
+ ))
3269
+
3270
+
3271
+ @app.command(name="checkpoints", help="List all autonomous time-travel snapshots in workspace.")
3272
+ def checkpoints_cmd(
3273
+ repo: str = typer.Option(".", "--repo", "-r", help="Repository directory."),
3274
+ ):
3275
+ """Displays saved workspace checkpoints."""
3276
+ from k_cli.git.checkpoint import CheckpointManager
3277
+ mgr = CheckpointManager(workspace_dir=repo)
3278
+ ckpts = mgr.list_checkpoints()
3279
+ if not ckpts:
3280
+ console.print("[yellow]No checkpoints saved yet in .kcli/checkpoints/[/yellow]")
3281
+ return
3282
+ table = Table(title="🛡️ K-CLI Time-Travel Checkpoints", border_style="cyan")
3283
+ table.add_column("Checkpoint ID", style="cyan bold")
3284
+ table.add_column("Timestamp", style="white")
3285
+ table.add_column("Files Tracked", style="green")
3286
+ table.add_column("Description", style="dim")
3287
+ for c in reversed(ckpts):
3288
+ ts = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(c["timestamp"]))
3289
+ table.add_row(c["checkpoint_id"], ts, str(len(c.get("files_tracked", []))), c.get("description", ""))
3290
+ console.print(table)
3291
+
3292
+
3293
+ @app.command(name="diff-last", help="Show unified diff between current workspace and latest checkpoint.")
3294
+ def diff_last_cmd(
3295
+ repo: str = typer.Option(".", "--repo", "-r", help="Repository directory."),
3296
+ ):
3297
+ """Displays diff since last checkpoint."""
3298
+ from k_cli.git.checkpoint import CheckpointManager
3299
+ mgr = CheckpointManager(workspace_dir=repo)
3300
+ diff_text = mgr.compute_diff()
3301
+ if "Zero modifications detected" in diff_text:
3302
+ console.print(f"[bold green]✔ {diff_text}[/bold green]")
3303
+ else:
3304
+ syntax = Syntax(diff_text, "diff", theme="monokai", line_numbers=True)
3305
+ console.print(syntax)
3306
+
3307
+
3308
+ # =============================================================================
3309
+ # Feature 2: Self-Learning Project Memory (`k-cli memory`)
3310
+ # =============================================================================
3311
+ @app.command(name="memory", help="View or update self-learning project memory (KCLI.md / .kcli/MEMORY.md).")
3312
+ def memory_cmd(
3313
+ action: str = typer.Argument("show", help="Action: 'show', 'init', or 'learn'."),
3314
+ note: Optional[str] = typer.Option(None, "--note", "-n", help="Lesson or directive to record."),
3315
+ repo: str = typer.Option(".", "--repo", "-r", help="Target repository directory."),
3316
+ ):
3317
+ """Inspects and manages persistent project memory."""
3318
+ from k_cli.core.memory import ProjectMemoryManager
3319
+ mgr = ProjectMemoryManager(workspace_dir=repo)
3320
+ if action == "init":
3321
+ mgr.initialize_if_missing()
3322
+ console.print("[bold green]✔ Initialized persistent KCLI.md project memory.[/bold green]")
3323
+ elif action == "learn" and note:
3324
+ mgr.record_learning(note, category="DeveloperNote")
3325
+ console.print(f"[bold green]✔ Recorded learning:[/bold green] {note}")
3326
+ else:
3327
+ content = mgr.load_memory(max_chars=8000)
3328
+ if not content:
3329
+ mgr.initialize_if_missing()
3330
+ content = mgr.load_memory(max_chars=8000)
3331
+ console.print(Panel(
3332
+ Markdown(content),
3333
+ title="🧠 K-CLI Self-Learning Project Memory (KCLI.md)",
3334
+ border_style="magenta",
3335
+ ))
3336
+
3337
+
3338
+ # =============================================================================
3339
+ # Feature 3: Standardized Evaluation & Benchmark Scorecard (`k-cli eval` / `benchmark`)
3340
+ # =============================================================================
3341
+ @app.command(name="eval", help="Run 5-battery standardized benchmark evaluation and export official scorecard.")
3342
+ @app.command(name="benchmark", help="Alias for k-cli eval: Run standardized autonomous developer benchmark.")
3343
+ def eval_cmd(
3344
+ repo: str = typer.Option(".", "--repo", "-r", help="Repository directory to evaluate."),
3345
+ json_out: bool = typer.Option(False, "--json", help="Output raw JSON benchmark data."),
3346
+ ):
3347
+ """Executes the quantitative 5-battery benchmark measuring AST pass rate and financial savings."""
3348
+ from k_cli.tools.benchmark_harness import EvaluationHarness
3349
+ harness = EvaluationHarness(workspace_dir=repo)
3350
+ console.print("[bold cyan]⚡ Running K-CLI Autonomous Engineering Benchmark Battery...[/bold cyan]")
3351
+ report = harness.run_full_evaluation()
3352
+
3353
+ if json_out:
3354
+ import dataclasses
3355
+ console.print(json.dumps(dataclasses.asdict(report), indent=2))
3356
+ return
3357
+
3358
+ table = Table(title="🏆 K-CLI Standardized Benchmark Scorecard", border_style="green")
3359
+ table.add_column("Task ID", style="bold cyan")
3360
+ table.add_column("Benchmark Task", style="white")
3361
+ table.add_column("Category", style="yellow")
3362
+ table.add_column("Status", style="bold green")
3363
+ table.add_column("AST Ground-Truth", style="bold green")
3364
+ table.add_column("Time", style="cyan")
3365
+ table.add_column("Cost Spent", style="magenta")
3366
+ table.add_column("Cost Saved", style="green")
3367
+
3368
+ for r in report.results:
3369
+ st = "[bold green]✔ PASS[/bold green]" if r.passed else "[bold red]✘ FAIL[/bold red]"
3370
+ ast_st = "[bold green]✔ VALID[/bold green]" if r.ast_verified else "[bold red]✘ FAIL[/bold red]"
3371
+ table.add_row(
3372
+ r.task_id,
3373
+ r.name,
3374
+ r.category,
3375
+ st,
3376
+ ast_st,
3377
+ f"{r.duration_sec}s",
3378
+ f"${r.actual_cost_usd:.4f}",
3379
+ f"${r.saved_usd:.4f}",
3380
+ )
3381
+ console.print(table)
3382
+
3383
+ summary_panel = Panel(
3384
+ f"[bold bright_white]Overall Pass Rate:[/bold bright_white] [bold green]{report.passed_tasks}/{report.total_tasks} ({report.ast_pass_rate_pct}% AST Verified)[/bold green]\n"
3385
+ f"[bold bright_white]Total Test Duration:[/bold bright_white] [cyan]{report.total_duration_sec}s[/cyan]\n"
3386
+ f"[bold bright_white]Actual Cloud/Model Spend:[/bold bright_white] [magenta]${report.total_spent_usd:.4f}[/magenta]\n"
3387
+ f"[bold bright_white]CreditSaver Optimization:[/bold bright_white] [bold green]${report.total_saved_usd:.4f} saved ({report.savings_pct}% cheaper than $10 unoptimized baseline)[/bold green]\n\n"
3388
+ f"[dim]Scorecard exported to: {repo}/.kcli/BENCHMARK_SCORECARD.md[/dim]",
3389
+ title="📊 Executive Evaluation Metrics",
3390
+ border_style="cyan",
3391
+ )
3392
+ console.print(summary_panel)
3393
+
3394
+
3395
+ # =============================================================================
3396
+ # Feature 4: Autonomous Docker & CI/CD Pipeline Healer (`k-cli cicd`)
3397
+ # =============================================================================
3398
+ @app.command(name="cicd", help="Audit and auto-repair broken GitHub Actions workflows and Dockerfiles.")
3399
+ def cicd_cmd(
3400
+ target: str = typer.Argument("all", help="Target: 'all', 'workflow', 'dockerfile', or specific path."),
3401
+ repo: str = typer.Option(".", "--repo", "-r", help="Repository directory."),
3402
+ dry_run: bool = typer.Option(False, "--dry-run", help="Audit only without writing changes."),
3403
+ ):
3404
+ """Diagnoses and heals broken CI/CD pipelines and Dockerfiles."""
3405
+ from k_cli.tools.cicd_healer import CICDHealer
3406
+ healer = CICDHealer(workspace_dir=repo)
3407
+ auto_apply = not dry_run
3408
+
3409
+ console.print(f"[bold cyan]⚡ Running K-CLI CI/CD & Docker Pipeline Healer on '{repo}'...[/bold cyan]\n")
3410
+ results = []
3411
+
3412
+ # Workflow healing
3413
+ wf_path = Path(repo) / ".github" / "workflows"
3414
+ if wf_path.exists():
3415
+ for wf_file in wf_path.glob("*.yml"):
3416
+ results.append(healer.audit_and_heal_workflow(str(wf_file), auto_apply=auto_apply))
3417
+ for wf_file in wf_path.glob("*.yaml"):
3418
+ results.append(healer.audit_and_heal_workflow(str(wf_file), auto_apply=auto_apply))
3419
+
3420
+ # Dockerfile healing
3421
+ df_path = Path(repo) / "Dockerfile"
3422
+ if df_path.exists():
3423
+ results.append(healer.audit_and_heal_dockerfile(str(df_path), auto_apply=auto_apply))
3424
+
3425
+ if not results:
3426
+ console.print("[yellow]No GitHub Actions workflows or Dockerfiles detected in repository.[/yellow]")
3427
+ return
3428
+
3429
+ for res in results:
3430
+ p_name = Path(res.file_path).name
3431
+ if res.issues_found > 0:
3432
+ console.print(Panel(
3433
+ f"[bold green]✔ Healed {res.issues_found} issue(s) in {p_name}:[/bold green]\n" +
3434
+ "\n".join(f" • {f}" for f in res.fixes_applied),
3435
+ title=f"🔧 CI/CD Healer: {p_name}",
3436
+ border_style="green",
3437
+ ))
3438
+ else:
3439
+ console.print(f"[green]✔[/green] {p_name}: [dim]All action versions, cache directives, and build layers verified optimal.[/dim]")
3440
+
3441
+
3442
+ # =============================================================================
3443
+ # Feature 5: Global Ambient Error Interceptor Sentinel (`k-cli wrap <cmd>`)
3444
+ # =============================================================================
3445
+ @app.command(name="wrap", help="Run ANY shell/pip/git command under ambient Sentinel supervision; auto-fixes errors in <1s.")
3446
+ @app.command(name="sentinel", help="Alias for k-cli wrap: Ambient zero-latency error interceptor.")
3447
+ def wrap_cmd(
3448
+ command: List[str] = typer.Argument(..., help="Shell command to execute and monitor."),
3449
+ repo: str = typer.Option(".", "--repo", "-r", help="Working directory for execution."),
3450
+ ):
3451
+ """Runs a command with Global Sentinel active. If any error occurs, Sentinel intercepts and heals it instantly."""
3452
+ from k_cli.tools.sentinel import GlobalSentinel
3453
+ import shlex
3454
+ cmd_str = shlex.join(command)
3455
+ console.print(f"[bold cyan]⚡ K-CLI Global Sentinel active on: [bold white]{cmd_str}[/bold white][/bold cyan]\n")
3456
+ sentinel = GlobalSentinel(workspace_dir=repo)
3457
+ result = sentinel.wrap_and_heal(cmd_str, cwd=repo)
3458
+
3459
+ if result.stdout.strip():
3460
+ console.print(result.stdout.strip())
3461
+ if result.stderr.strip() and result.final_exit_code != 0:
3462
+ console.print(f"[red]{result.stderr.strip()}[/red]")
3463
+
3464
+ if result.original_exit_code == 0:
3465
+ console.print(f"\n[bold green]✔ Command completed successfully ({result.duration_sec}s)[/bold green]")
3466
+ elif result.repair_successful:
3467
+ console.print(Panel(
3468
+ f"[bold green]✔ Sentinel Auto-Repaired Command in {result.duration_sec}s[/bold green]\n\n"
3469
+ f"• [cyan]Intercepted Error:[/cyan] {result.culprit_detected}\n"
3470
+ f"• [yellow]Action Taken:[/yellow] {result.repair_action}\n"
3471
+ f"• [green]Final Status:[/green] Exit Code {result.final_exit_code} (VERIFIED RE-EXECUTION SUCCESS)",
3472
+ title="🛡️ K-CLI Global Sentinel Interception",
3473
+ border_style="green",
3474
+ ))
3475
+ else:
3476
+ console.print(Panel(
3477
+ f"[bold red]✘ Sentinel Intercepted Error (Exit Code {result.final_exit_code})[/bold red]\n\n"
3478
+ f"• [cyan]Culprit:[/cyan] {result.culprit_detected}\n"
3479
+ f"• [yellow]Intervention:[/yellow] {result.repair_action}",
3480
+ title="⚠️ K-CLI Sentinel Warning",
3481
+ border_style="yellow",
3482
+ ))
3483
+ raise typer.Exit(code=result.final_exit_code)
3484
+
3485
+
3244
3486
  def interactive_mode(model: str = "qwen2.5-coder:1.5b", mock: bool = False, continue_session: bool = False):
3245
3487
  """Interactive multi-turn prompt shell when typing 'k' without arguments."""
3246
3488
  if hasattr(console, "is_terminal") and console.is_terminal: