Skip to content

Commit cd2b0f7

Browse files
committed
Merge PR #1579: refine platform policy and memory skill docs
2 parents e7bd514 + 4715321 commit cd2b0f7

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

nanobot/agent/context.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ def _get_identity(self) -> str:
5959
system = platform.system()
6060
runtime = f"{'macOS' if system == 'Darwin' else system} {platform.machine()}, Python {platform.python_version()}"
6161

62+
platform_policy = ""
63+
if system == "Windows":
64+
platform_policy = """## Platform Policy (Windows)
65+
- You are running on Windows. Do not assume GNU tools like `grep`, `sed`, or `awk` exist.
66+
- Prefer Windows-native commands or file tools when they are more reliable.
67+
- If terminal output is garbled, retry with UTF-8 output enabled.
68+
"""
69+
else:
70+
platform_policy = """## Platform Policy (POSIX)
71+
- You are running on a POSIX system. Prefer UTF-8 and standard shell tools.
72+
- Use file tools when they are simpler or more reliable than shell commands.
73+
"""
74+
6275
return f"""# nanobot 🐈
6376
6477
You are nanobot, a helpful AI assistant.
@@ -72,6 +85,8 @@ def _get_identity(self) -> str:
7285
- History log: {workspace_path}/memory/HISTORY.md (grep-searchable). Each entry starts with [YYYY-MM-DD HH:MM].
7386
- Custom skills: {workspace_path}/skills/{{skill-name}}/SKILL.md
7487
88+
{platform_policy}
89+
7590
## nanobot Guidelines
7691
- State intent before tool calls, but NEVER predict or claim results before receiving them.
7792
- Before modifying a file, read it first. Do not assume files or directories exist.

nanobot/skills/memory/SKILL.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@ always: true
99
## Structure
1010

1111
- `memory/MEMORY.md` — Long-term facts (preferences, project context, relationships). Always loaded into your context.
12-
- `memory/HISTORY.md` — Append-only event log. NOT loaded into context. Search it with grep. Each entry starts with [YYYY-MM-DD HH:MM].
12+
- `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].
1313

1414
## Search Past Events
1515

16-
```bash
17-
grep -i "keyword" memory/HISTORY.md
18-
```
16+
Choose the search method based on file size:
1917

20-
Use the `exec` tool to run grep. Combine patterns: `grep -iE "meeting|deadline" memory/HISTORY.md`
18+
- Small `memory/HISTORY.md`: use `read_file`, then search in-memory
19+
- Large or long-lived `memory/HISTORY.md`: use the `exec` tool for targeted search
20+
21+
Examples:
22+
- **Linux/macOS:** `grep -i "keyword" memory/HISTORY.md`
23+
- **Windows:** `findstr /i "keyword" memory\HISTORY.md`
24+
- **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:]))"`
25+
26+
Prefer targeted command-line search for large history files.
2127

2228
## When to Update MEMORY.md
2329

0 commit comments

Comments
 (0)