diff --git a/nanobot/agent/context.py b/nanobot/agent/context.py index 820baf5..2c648eb 100644 --- a/nanobot/agent/context.py +++ b/nanobot/agent/context.py @@ -59,6 +59,19 @@ Skills with available="false" need dependencies installed first - you can try in system = platform.system() runtime = f"{'macOS' if system == 'Darwin' else system} {platform.machine()}, Python {platform.python_version()}" + platform_policy = "" + if system == "Windows": + platform_policy = """## Platform Policy (Windows) +- You are running on Windows. Do not assume GNU tools like `grep`, `sed`, or `awk` exist. +- Prefer Windows-native commands or file tools when they are more reliable. +- If terminal output is garbled, retry with UTF-8 output enabled. +""" + else: + platform_policy = """## Platform Policy (POSIX) +- You are running on a POSIX system. Prefer UTF-8 and standard shell tools. +- Use file tools when they are simpler or more reliable than shell commands. +""" + return f"""# nanobot 🐈 You are nanobot, a helpful AI assistant. @@ -72,6 +85,8 @@ Your workspace is at: {workspace_path} - History log: {workspace_path}/memory/HISTORY.md (grep-searchable). Each entry starts with [YYYY-MM-DD HH:MM]. - Custom skills: {workspace_path}/skills/{{skill-name}}/SKILL.md +{platform_policy} + ## nanobot Guidelines - State intent before tool calls, but NEVER predict or claim results before receiving them. - Before modifying a file, read it first. Do not assume files or directories exist. diff --git a/nanobot/skills/memory/SKILL.md b/nanobot/skills/memory/SKILL.md index 529a02d..3f0a8fc 100644 --- a/nanobot/skills/memory/SKILL.md +++ b/nanobot/skills/memory/SKILL.md @@ -9,15 +9,21 @@ always: true ## Structure - `memory/MEMORY.md` — Long-term facts (preferences, project context, relationships). Always loaded into your context. -- `memory/HISTORY.md` — Append-only event log. NOT loaded into context. Search it with grep. Each entry starts with [YYYY-MM-DD HH:MM]. +- `memory/HISTORY.md` — Append-only event log. NOT loaded into context. Search it with grep-style tools or in-memory filters. Each entry starts with [YYYY-MM-DD HH:MM]. ## Search Past Events -```bash -grep -i "keyword" memory/HISTORY.md -``` +Choose the search method based on file size: -Use the `exec` tool to run grep. Combine patterns: `grep -iE "meeting|deadline" memory/HISTORY.md` +- Small `memory/HISTORY.md`: use `read_file`, then search in-memory +- Large or long-lived `memory/HISTORY.md`: use the `exec` tool for targeted search + +Examples: +- **Linux/macOS:** `grep -i "keyword" memory/HISTORY.md` +- **Windows:** `findstr /i "keyword" memory\HISTORY.md` +- **Cross-platform Python:** `python -c "from pathlib import Path; text = Path('memory/HISTORY.md').read_text(encoding='utf-8'); print('\n'.join([l for l in text.splitlines() if 'keyword' in l.lower()][-20:]))"` + +Prefer targeted command-line search for large history files. ## When to Update MEMORY.md