Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions code_puppy/agents/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,12 @@ def reload_code_generation_agent(self, message_group: Optional[str] = None):
register_tools_for_agent,
)

# Invalidate the project-local rules cache so a fresh read from the
# current working directory is performed on the next load_puppy_rules()
# call. This is critical for /cd: the user may have switched to a
# different project that has its own AGENT.md (or none at all).
self._puppy_rules = None

if message_group is None:
message_group = str(uuid.uuid4())

Expand Down
16 changes: 15 additions & 1 deletion code_puppy/command_line/core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def handle_cd_command(command: str) -> bool:
# Use shlex.split to handle quoted paths properly
import shlex

from code_puppy.messaging import emit_error, emit_info, emit_success
from code_puppy.messaging import emit_error, emit_info, emit_success, emit_warning

try:
tokens = shlex.split(command)
Expand All @@ -77,6 +77,20 @@ def handle_cd_command(command: str) -> bool:
if os.path.isdir(target):
os.chdir(target)
emit_success(f"Changed directory to: {target}")
# Reload the agent so the system prompt and project-local
# AGENT.md rules reflect the new working directory. Without
# this, the LLM keeps receiving stale path information for the
# remainder of the session (the PydanticAgent instructions are
# baked in at construction time and never refreshed otherwise).
try:
from code_puppy.agents.agent_manager import get_current_agent

get_current_agent().reload_code_generation_agent()
except Exception as e:
emit_warning(
f"Directory changed, but agent reload failed: {e}. "
"You may need to run /agent or /model to force a refresh."
)
else:
emit_error(f"Not a directory: {dirname}")
return True
Expand Down
34 changes: 33 additions & 1 deletion code_puppy/mcp_/server_registry_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def get_environment_vars(self) -> List[str]:
# Also check config for env vars (existing logic)
if "env" in self.config:
for _key, value in self.config["env"].items():
if isinstance(value, str) and value.startswith("$"):
if (
isinstance(value, str)
and value.startswith("$")
and not value.startswith("${")
):
var_name = value[1:]
if var_name not in env_vars:
env_vars.append(var_name)
Expand Down Expand Up @@ -460,6 +464,34 @@ def to_server_config(self, custom_name: Optional[str] = None, **cmd_args) -> Dic
),
),
# ========== Web & Browser ==========
MCPServerTemplate(
id="lightpanda",
name="lightpanda",
display_name="Lightpanda Browser",
description="Headless browser automation using a Lightpanda CDP endpoint",
category="Web",
tags=["browser", "web", "scraping", "automation", "lightpanda", "cdp"],
type="stdio",
config={
"command": "npx",
"args": ["-y", "openclaw-lightpanda-mcp"],
"env": {"LIGHTPANDA_CDP_URL": "${cdp_url}"},
"timeout": 60,
},
requires=MCPServerRequirements(
command_line_args=[
{
"name": "cdp_url",
"prompt": "Lightpanda CDP URL",
"default": "ws://127.0.0.1:9222",
"required": False,
}
],
required_tools=["node", "npm", "npx", "lightpanda"],
package_dependencies=["openclaw-lightpanda-mcp"],
system_requirements=["Running Lightpanda CDP endpoint"],
),
),
MCPServerTemplate(
id="puppeteer",
name="puppeteer",
Expand Down
2 changes: 1 addition & 1 deletion code_puppy/tools/browser/browser_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async def browser_initialize(

Args:
headless: Run browser in headless mode (no GUI)
browser_type: Browser engine (chromium, firefox, webkit)
browser_type: Browser engine (chromium, firefox, webkit, lightpanda)
homepage: Initial page to load

Returns:
Expand Down
Loading