Merge branch 'main' into pr-1579 and tighten platform guidance

This commit is contained in:
Re-bin
2026-03-08 16:39:37 +00:00
parent ce9b516b11
commit 4715321319
2 changed files with 13 additions and 25 deletions

View File

@@ -62,27 +62,14 @@ Skills with available="false" need dependencies installed first - you can try in
platform_policy = "" platform_policy = ""
if system == "Windows": if system == "Windows":
platform_policy = """## Platform Policy (Windows) platform_policy = """## Platform Policy (Windows)
- You are running on Windows. Shell commands executed via the `exec` tool run under the default Windows shell (PowerShell or cmd.exe) unless you explicitly invoke another shell. - You are running on Windows. Do not assume GNU tools like `grep`, `sed`, or `awk` exist.
- Prefer UTF-8 for file I/O and command output. If terminal output is garbled/mojibake, retry with: - Prefer Windows-native commands or file tools when they are more reliable.
- PowerShell: `[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; <command>` - If terminal output is garbled, retry with UTF-8 output enabled.
- cmd.exe: `chcp 65001 >NUL & <command>`
- Do NOT assume GNU tools like `grep`, `sed`, `awk` exist. Prefer Windows built-ins:
- Search text: `findstr /i "keyword" path\\to\\file`
- List files: `dir`
- Show file: `type path\\to\\file`
- When in doubt, prefer the file tools (`read_file`, `list_dir`) over shell for portability and reliability.
"""
elif system == "Darwin":
platform_policy = """## Platform Policy (macOS)
- You are running on macOS. Prefer POSIX tools and UTF-8.
- Use forward-slash paths. Prefer `ls`, `cat`, `grep`, `find` for filesystem and text operations.
- When in doubt, prefer the file tools (`read_file`, `list_dir`) over shell for portability and reproducibility.
""" """
else: else:
platform_policy = """## Platform Policy (Linux) platform_policy = """## Platform Policy (POSIX)
- You are running on Linux. Prefer POSIX tools and UTF-8. - You are running on a POSIX system. Prefer UTF-8 and standard shell tools.
- Use forward-slash paths. Prefer `ls`, `cat`, `grep`, `find` for filesystem and text operations. - Use file tools when they are simpler or more reliable than shell commands.
- When in doubt, prefer the file tools (`read_file`, `list_dir`) over shell for portability and reproducibility.
""" """
return f"""# nanobot 🐈 return f"""# nanobot 🐈

View File

@@ -13,16 +13,17 @@ always: true
## Search Past Events ## Search Past Events
**Recommended approach (cross-platform):** Choose the search method based on file size:
- Use `read_file` to read `memory/HISTORY.md`, then search in-memory
- This is the most reliable and portable method on all platforms
**Alternative (if you need command-line search):** - 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` - **Linux/macOS:** `grep -i "keyword" memory/HISTORY.md`
- **Windows:** `findstr /i "keyword" memory\HISTORY.md` - **Windows:** `findstr /i "keyword" memory\HISTORY.md`
- **Python (cross-platform):** `python -c "import re; content=open('memory/HISTORY.md', encoding='utf-8').read(); print('\n'.join([l for l in content.split('\n') if 'keyword' in l.lower()][-20:]))"` - **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:]))"`
Use the `exec` tool to run these commands. For complex searches, prefer `read_file` + in-memory filtering. Prefer targeted command-line search for large history files.
## When to Update MEMORY.md ## When to Update MEMORY.md