mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 20:15:20 +00:00
Add print-system-prompt command to output InitialInstructionsTool result
This command creates a SerenaAgent instance for a project and uses the InitialInstructionsTool to output the system prompt/initial instructions. It follows the same pattern as the existing index-project command and can be run with: uv run print-system-prompt [project_path] 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
85ee10662b
commit
f654e1fe25
2 files changed
+28
No files matched your search
@@ -39,6 +39,7 @@ dependencies = [
|
||||
[project.scripts]
|
||||
serena-mcp-server = "serena.mcp:start_mcp_server"
|
||||
index-project = "serena.agent:index_project"
|
||||
print-system-prompt = "serena.agent:print_system_prompt"
|
||||
|
||||
[project.license]
|
||||
text = "MIT"
|
||||
|
||||
@@ -124,6 +124,33 @@ def index_project(project: str, log_level: str = "INFO") -> None:
|
||||
print(f"Symbols saved to {ls.cache_path}")
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument("project", type=click.Path(exists=True), required=False, default=os.getcwd())
|
||||
@click.option("--log-level", type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]), default="WARNING")
|
||||
def print_system_prompt(project: str, log_level: str = "WARNING") -> None:
|
||||
"""
|
||||
Print the system prompt (initial instructions) for a project.
|
||||
|
||||
:param project: the project to get the system prompt for. By default, the current working directory is used.
|
||||
"""
|
||||
log_level_int = logging.getLevelNamesMapping()[log_level.upper()]
|
||||
logging.configure(level=log_level_int)
|
||||
|
||||
# Create a SerenaAgent instance
|
||||
agent = SerenaAgent(project=os.path.abspath(project))
|
||||
|
||||
# Get the InitialInstructionsTool instance
|
||||
from serena.tools.workflow_tools import InitialInstructionsTool
|
||||
|
||||
initial_instructions_tool = agent.get_tool(InitialInstructionsTool)
|
||||
|
||||
# Apply the tool to get the system prompt
|
||||
system_prompt = initial_instructions_tool.apply()
|
||||
|
||||
# Print the system prompt
|
||||
print(system_prompt)
|
||||
|
||||
|
||||
class SerenaAgent:
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
Reference in new issue
Block a user