minion-code 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. examples/cli_entrypoint.py +60 -0
  2. examples/{agent_with_todos.py → components/agent_with_todos.py} +58 -47
  3. examples/{message_response_children_demo.py → components/message_response_children_demo.py} +61 -55
  4. examples/components/messages_component.py +199 -0
  5. examples/file_freshness_example.py +22 -22
  6. examples/file_watching_example.py +32 -26
  7. examples/interruptible_tui.py +921 -3
  8. examples/repl_tui.py +129 -0
  9. examples/skills/example_usage.py +57 -0
  10. examples/start.py +173 -0
  11. minion_code/__init__.py +1 -1
  12. minion_code/acp_server/__init__.py +34 -0
  13. minion_code/acp_server/agent.py +539 -0
  14. minion_code/acp_server/hooks.py +354 -0
  15. minion_code/acp_server/main.py +194 -0
  16. minion_code/acp_server/permissions.py +142 -0
  17. minion_code/acp_server/test_client.py +104 -0
  18. minion_code/adapters/__init__.py +22 -0
  19. minion_code/adapters/output_adapter.py +207 -0
  20. minion_code/adapters/rich_adapter.py +169 -0
  21. minion_code/adapters/textual_adapter.py +254 -0
  22. minion_code/agents/__init__.py +2 -2
  23. minion_code/agents/code_agent.py +517 -104
  24. minion_code/agents/hooks.py +378 -0
  25. minion_code/cli.py +538 -429
  26. minion_code/cli_simple.py +665 -0
  27. minion_code/commands/__init__.py +136 -29
  28. minion_code/commands/clear_command.py +19 -46
  29. minion_code/commands/help_command.py +33 -49
  30. minion_code/commands/history_command.py +37 -55
  31. minion_code/commands/model_command.py +194 -0
  32. minion_code/commands/quit_command.py +9 -12
  33. minion_code/commands/resume_command.py +181 -0
  34. minion_code/commands/skill_command.py +89 -0
  35. minion_code/commands/status_command.py +48 -73
  36. minion_code/commands/tools_command.py +54 -52
  37. minion_code/commands/version_command.py +34 -69
  38. minion_code/components/ConfirmDialog.py +430 -0
  39. minion_code/components/Message.py +318 -97
  40. minion_code/components/MessageResponse.py +30 -29
  41. minion_code/components/Messages.py +351 -0
  42. minion_code/components/PromptInput.py +499 -245
  43. minion_code/components/__init__.py +24 -17
  44. minion_code/const.py +7 -0
  45. minion_code/screens/REPL.py +1453 -469
  46. minion_code/screens/__init__.py +1 -1
  47. minion_code/services/__init__.py +20 -20
  48. minion_code/services/event_system.py +19 -14
  49. minion_code/services/file_freshness_service.py +223 -170
  50. minion_code/skills/__init__.py +25 -0
  51. minion_code/skills/skill.py +128 -0
  52. minion_code/skills/skill_loader.py +198 -0
  53. minion_code/skills/skill_registry.py +177 -0
  54. minion_code/subagents/__init__.py +31 -0
  55. minion_code/subagents/builtin/__init__.py +30 -0
  56. minion_code/subagents/builtin/claude_code_guide.py +32 -0
  57. minion_code/subagents/builtin/explore.py +36 -0
  58. minion_code/subagents/builtin/general_purpose.py +19 -0
  59. minion_code/subagents/builtin/plan.py +61 -0
  60. minion_code/subagents/subagent.py +116 -0
  61. minion_code/subagents/subagent_loader.py +147 -0
  62. minion_code/subagents/subagent_registry.py +151 -0
  63. minion_code/tools/__init__.py +8 -2
  64. minion_code/tools/bash_tool.py +16 -3
  65. minion_code/tools/file_edit_tool.py +201 -104
  66. minion_code/tools/file_read_tool.py +183 -26
  67. minion_code/tools/file_write_tool.py +17 -3
  68. minion_code/tools/glob_tool.py +23 -2
  69. minion_code/tools/grep_tool.py +229 -21
  70. minion_code/tools/ls_tool.py +28 -3
  71. minion_code/tools/multi_edit_tool.py +89 -84
  72. minion_code/tools/python_interpreter_tool.py +9 -1
  73. minion_code/tools/skill_tool.py +210 -0
  74. minion_code/tools/task_tool.py +287 -0
  75. minion_code/tools/todo_read_tool.py +28 -24
  76. minion_code/tools/todo_write_tool.py +82 -65
  77. minion_code/{types.py → type_defs.py} +15 -2
  78. minion_code/utils/__init__.py +45 -17
  79. minion_code/utils/config.py +610 -0
  80. minion_code/utils/history.py +114 -0
  81. minion_code/utils/logs.py +53 -0
  82. minion_code/utils/mcp_loader.py +153 -55
  83. minion_code/utils/output_truncator.py +233 -0
  84. minion_code/utils/session_storage.py +369 -0
  85. minion_code/utils/todo_file_utils.py +26 -22
  86. minion_code/utils/todo_storage.py +43 -33
  87. minion_code/web/__init__.py +9 -0
  88. minion_code/web/adapters/__init__.py +5 -0
  89. minion_code/web/adapters/web_adapter.py +524 -0
  90. minion_code/web/api/__init__.py +7 -0
  91. minion_code/web/api/chat.py +277 -0
  92. minion_code/web/api/interactions.py +136 -0
  93. minion_code/web/api/sessions.py +135 -0
  94. minion_code/web/server.py +149 -0
  95. minion_code/web/services/__init__.py +5 -0
  96. minion_code/web/services/session_manager.py +420 -0
  97. minion_code-0.1.2.dist-info/METADATA +476 -0
  98. minion_code-0.1.2.dist-info/RECORD +111 -0
  99. {minion_code-0.1.0.dist-info → minion_code-0.1.2.dist-info}/WHEEL +1 -1
  100. minion_code-0.1.2.dist-info/entry_points.txt +6 -0
  101. tests/test_adapter.py +67 -0
  102. tests/test_adapter_simple.py +79 -0
  103. tests/test_file_read_tool.py +144 -0
  104. tests/test_readonly_tools.py +0 -2
  105. tests/test_skills.py +441 -0
  106. examples/advance_tui.py +0 -508
  107. examples/rich_example.py +0 -4
  108. examples/simple_file_watching.py +0 -57
  109. examples/simple_tui.py +0 -267
  110. examples/simple_usage.py +0 -69
  111. minion_code-0.1.0.dist-info/METADATA +0 -350
  112. minion_code-0.1.0.dist-info/RECORD +0 -59
  113. minion_code-0.1.0.dist-info/entry_points.txt +0 -4
  114. {minion_code-0.1.0.dist-info → minion_code-0.1.2.dist-info}/licenses/LICENSE +0 -0
  115. {minion_code-0.1.0.dist-info → minion_code-0.1.2.dist-info}/top_level.txt +0 -0
examples/repl_tui.py ADDED
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ REPL TUI Entry Point
5
+
6
+ This is the main entry point for the modern TUI REPL interface.
7
+ It provides a clean way to start the REPL from examples/ directory.
8
+ """
9
+
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ # Add project root to path
14
+ sys.path.insert(0, str(Path(__file__).parent.parent))
15
+
16
+
17
+ def run():
18
+ """Main entry point for REPL TUI"""
19
+ try:
20
+ # Setup TUI-friendly logging before importing REPL
21
+ from minion_code.utils.logs import setup_tui_logging
22
+
23
+ setup_tui_logging()
24
+
25
+ from minion_code.screens.REPL import run as run_repl
26
+
27
+ run_repl()
28
+ except ImportError as e:
29
+ print(f"❌ TUI dependencies not available: {e}")
30
+ print("💡 Install with: pip install textual rich")
31
+ print("🔄 Falling back to console interface...")
32
+ # Fallback to console
33
+ from minion_code.cli_simple import app
34
+
35
+ app()
36
+ except Exception as e:
37
+ print(f"❌ Error starting REPL: {e}")
38
+ sys.exit(1)
39
+
40
+
41
+ def run_with_args():
42
+ """Entry point that handles command line arguments"""
43
+ import argparse
44
+
45
+ parser = argparse.ArgumentParser(
46
+ description="🤖 MinionCodeAgent REPL TUI",
47
+ formatter_class=argparse.RawDescriptionHelpFormatter,
48
+ epilog="""
49
+ Examples:
50
+ python examples/repl_tui.py
51
+ python examples/repl_tui.py --debug --verbose
52
+ python examples/repl_tui.py --prompt "Help me analyze this code"
53
+ python examples/repl_tui.py --dir /path/to/project
54
+ """,
55
+ )
56
+
57
+ parser.add_argument("--debug", action="store_true", help="Enable debug mode")
58
+
59
+ parser.add_argument(
60
+ "--verbose", "-v", action="store_true", help="Enable verbose output"
61
+ )
62
+
63
+ parser.add_argument(
64
+ "--prompt", "-p", type=str, help="Initial prompt to send to the agent"
65
+ )
66
+
67
+ parser.add_argument(
68
+ "--dir", "-d", type=str, help="Change to specified directory before starting"
69
+ )
70
+
71
+ parser.add_argument(
72
+ "--test-messages",
73
+ action="store_true",
74
+ help="Start with test messages for development",
75
+ )
76
+
77
+ args = parser.parse_args()
78
+
79
+ # Change directory if specified
80
+ if args.dir:
81
+ import os
82
+
83
+ try:
84
+ target_dir = Path(args.dir).resolve()
85
+ if not target_dir.exists():
86
+ print(f"❌ Directory does not exist: {args.dir}")
87
+ sys.exit(1)
88
+ if not target_dir.is_dir():
89
+ print(f"❌ Path is not a directory: {args.dir}")
90
+ sys.exit(1)
91
+
92
+ os.chdir(target_dir)
93
+ if args.verbose:
94
+ print(f"📁 Changed to directory: {target_dir}")
95
+ except Exception as e:
96
+ print(f"❌ Failed to change directory: {e}")
97
+ sys.exit(1)
98
+
99
+ # Start REPL with arguments
100
+ try:
101
+ # Setup TUI-friendly logging before importing REPL
102
+ from minion_code.utils.logs import setup_tui_logging
103
+
104
+ setup_tui_logging()
105
+
106
+ if args.test_messages:
107
+ # Use the test messages version
108
+ from examples.repl_with_test_messages import main as run_test_repl
109
+
110
+ run_test_repl()
111
+ else:
112
+ from minion_code.screens.REPL import run as run_repl
113
+
114
+ run_repl(initial_prompt=args.prompt, debug=args.debug, verbose=args.verbose)
115
+ except ImportError as e:
116
+ print(f"❌ TUI dependencies not available: {e}")
117
+ print("💡 Install with: pip install textual rich")
118
+ sys.exit(1)
119
+ except Exception as e:
120
+ print(f"❌ Error starting REPL: {e}")
121
+ if args.verbose:
122
+ import traceback
123
+
124
+ traceback.print_exc()
125
+ sys.exit(1)
126
+
127
+
128
+ if __name__ == "__main__":
129
+ run_with_args()
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ Example: MinionCodeAgent with Skill Tool
5
+
6
+ This script demonstrates using MinionCodeAgent with the built-in SkillTool.
7
+ """
8
+
9
+ import asyncio
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ # Add project root to path
14
+ sys.path.insert(0, str(Path(__file__).parent.parent.parent))
15
+
16
+ from minion_code.agents.code_agent import MinionCodeAgent
17
+
18
+
19
+ async def main():
20
+ """Demonstrate MinionCodeAgent with skill tool."""
21
+ print("=" * 60)
22
+ print("MinionCodeAgent with Skill Tool Example")
23
+ print("=" * 60 + "\n")
24
+
25
+ # Create agent - SkillTool is included by default
26
+ print("Creating MinionCodeAgent...")
27
+ agent = await MinionCodeAgent.create(name="Skill Demo Agent", llm="sonnet")
28
+ print("✓ Agent created with SkillTool\n")
29
+
30
+ # Show available tools (including SkillTool)
31
+ print("Available tools:")
32
+ tools_info = agent.get_tools_info()
33
+ for tool in tools_info:
34
+ if "skill" in tool["name"].lower():
35
+ print(f" ★ {tool['name']}: {tool['description']}")
36
+ else:
37
+ print(f" - {tool['name']}")
38
+ print()
39
+
40
+ # Ask agent to list available skills
41
+ print("Asking agent to list available skills...")
42
+ print("-" * 40)
43
+
44
+ response = await agent.run_async("Please read Titans.pdf and give a summary")
45
+
46
+ print(
47
+ f"\nAgent response:\n{response.answer if hasattr(response, 'answer') else response}"
48
+ )
49
+ print()
50
+
51
+ print("=" * 60)
52
+ print("Example completed!")
53
+ print("=" * 60)
54
+
55
+
56
+ if __name__ == "__main__":
57
+ asyncio.run(main())
examples/start.py ADDED
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ Universal Start Script for MinionCodeAgent
5
+
6
+ This script provides a unified way to start any interface of MinionCodeAgent.
7
+ It automatically detects the best available interface and provides fallbacks.
8
+ """
9
+
10
+ import sys
11
+ import os
12
+ from pathlib import Path
13
+
14
+ # Add project root to path
15
+ sys.path.insert(0, str(Path(__file__).parent.parent))
16
+
17
+
18
+ def check_tui_available():
19
+ """Check if TUI dependencies are available"""
20
+ try:
21
+ import textual
22
+ import rich
23
+
24
+ return True
25
+ except ImportError:
26
+ return False
27
+
28
+
29
+ def show_interface_menu():
30
+ """Show interface selection menu"""
31
+ print("🤖 MinionCodeAgent - Choose Interface")
32
+ print("=" * 40)
33
+ print("1. 🖥️ Modern TUI REPL (Recommended)")
34
+ print("2. 🖥️ Console CLI (Traditional)")
35
+ print("3. ❓ Auto-detect best interface")
36
+ print("4. 🚪 Exit")
37
+ print()
38
+
39
+ while True:
40
+ try:
41
+ choice = input("Select interface (1-4): ").strip()
42
+ if choice in ["1", "2", "3", "4"]:
43
+ return choice
44
+ else:
45
+ print("❌ Invalid choice. Please enter 1, 2, 3, or 4.")
46
+ except (EOFError, KeyboardInterrupt):
47
+ print("\n👋 Goodbye!")
48
+ sys.exit(0)
49
+
50
+
51
+ def start_tui_repl():
52
+ """Start TUI REPL interface"""
53
+ print("🚀 Starting TUI REPL interface...")
54
+ try:
55
+ from minion_code.screens.REPL import run
56
+
57
+ run()
58
+ except ImportError as e:
59
+ print(f"❌ TUI dependencies not available: {e}")
60
+ print("💡 Install with: pip install textual rich")
61
+ return False
62
+ except Exception as e:
63
+ print(f"❌ Error starting TUI REPL: {e}")
64
+ return False
65
+ return True
66
+
67
+
68
+ def start_console_cli():
69
+ """Start console CLI interface"""
70
+ print("🚀 Starting console CLI interface...")
71
+ try:
72
+ from minion_code.cli_simple import InterruptibleCLI
73
+ import asyncio
74
+
75
+ cli = InterruptibleCLI()
76
+ asyncio.run(cli.run())
77
+ except Exception as e:
78
+ print(f"❌ Error starting console CLI: {e}")
79
+ return False
80
+ return True
81
+
82
+
83
+ def auto_detect_interface():
84
+ """Auto-detect and start the best available interface"""
85
+ print("🔍 Auto-detecting best interface...")
86
+
87
+ if check_tui_available():
88
+ print("✅ TUI dependencies available - starting TUI REPL")
89
+ return start_tui_repl()
90
+ else:
91
+ print("⚠️ TUI dependencies not available - starting console CLI")
92
+ return start_console_cli()
93
+
94
+
95
+ def main():
96
+ """Main entry point"""
97
+ print("🤖 MinionCodeAgent Universal Launcher")
98
+ print("=" * 50)
99
+
100
+ # Check if command line arguments are provided
101
+ if len(sys.argv) > 1:
102
+ arg = sys.argv[1].lower()
103
+
104
+ if arg in ["repl", "tui", "r"]:
105
+ if not start_tui_repl():
106
+ print("🔄 Falling back to console CLI...")
107
+ start_console_cli()
108
+ elif arg in ["console", "cli", "c"]:
109
+ start_console_cli()
110
+ elif arg in ["auto", "a"]:
111
+ auto_detect_interface()
112
+ elif arg in ["help", "h", "--help", "-h"]:
113
+ print_help()
114
+ else:
115
+ print(f"❌ Unknown argument: {arg}")
116
+ print_help()
117
+ sys.exit(1)
118
+ else:
119
+ # Interactive mode
120
+ choice = show_interface_menu()
121
+
122
+ if choice == "1":
123
+ if not start_tui_repl():
124
+ print("🔄 Falling back to console CLI...")
125
+ start_console_cli()
126
+ elif choice == "2":
127
+ start_console_cli()
128
+ elif choice == "3":
129
+ auto_detect_interface()
130
+ elif choice == "4":
131
+ print("👋 Goodbye!")
132
+ sys.exit(0)
133
+
134
+
135
+ def print_help():
136
+ """Print help information"""
137
+ print(
138
+ """
139
+ Usage: python examples/start.py [INTERFACE]
140
+
141
+ Interfaces:
142
+ repl, tui, r Start TUI REPL interface (recommended)
143
+ console, cli, c Start console CLI interface
144
+ auto, a Auto-detect best interface
145
+ help, h Show this help
146
+
147
+ Examples:
148
+ python examples/start.py repl
149
+ python examples/start.py console
150
+ python examples/start.py auto
151
+ python examples/start.py
152
+
153
+ If no interface is specified, an interactive menu will be shown.
154
+
155
+ Dependencies:
156
+ TUI REPL requires: textual, rich
157
+ Console CLI requires: typer, rich (basic)
158
+
159
+ Install TUI dependencies:
160
+ pip install textual rich
161
+ """
162
+ )
163
+
164
+
165
+ if __name__ == "__main__":
166
+ try:
167
+ main()
168
+ except KeyboardInterrupt:
169
+ print("\n👋 Goodbye!")
170
+ sys.exit(0)
171
+ except Exception as e:
172
+ print(f"❌ Unexpected error: {e}")
173
+ sys.exit(1)
minion_code/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  """
4
4
  Minion Code Tools Package
5
5
 
6
- A collection of tools and enhanced agents for the Minion framework including
6
+ A collection of tools and enhanced agents for the Minion framework including
7
7
  file operations, system commands, web interactions, and specialized agents
8
8
  with dynamic system prompts and state management.
9
9
  """
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ ACP (Agent Client Protocol) integration for minion-code.
5
+
6
+ This module provides ACP server implementation allowing minion-code
7
+ to be used with ACP-compatible clients like Zed editor.
8
+
9
+ Note: Imports are lazy to avoid circular import issues with the external 'acp' package.
10
+ Use: from minion_code.acp.agent import MinionACPAgent
11
+ """
12
+
13
+ __all__ = [
14
+ "MinionACPAgent",
15
+ "create_acp_hooks",
16
+ "ACPToolHooks",
17
+ ]
18
+
19
+
20
+ def __getattr__(name):
21
+ """Lazy imports to avoid circular import with external 'acp' package."""
22
+ if name == "MinionACPAgent":
23
+ from .agent import MinionACPAgent
24
+
25
+ return MinionACPAgent
26
+ elif name == "create_acp_hooks":
27
+ from .hooks import create_acp_hooks
28
+
29
+ return create_acp_hooks
30
+ elif name == "ACPToolHooks":
31
+ from .hooks import ACPToolHooks
32
+
33
+ return ACPToolHooks
34
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")