Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
feat(vibey): tell the agent to look for instruction files below the cwd (C-7 section 9) (#2514)
Call White5d7af6f9efb6
diff --git a/README.md b/README.mdindex 96cac4b57..017da8278 100644--- a/README.md+++ b/README.md@@ -277,7 +277,7 @@ Full references: [Commands](docs/COMMANDS.md) · [CLI](docs/CLI.md)1. `~/.avibe/AGENTS.md`, for every project;2. then, in each directory from the filesystem root down to the working directory, its `AGENTS.md` (or `CLAUDE.md`).-`AGENTS.override.md` takes the place of a directory's `AGENTS.md`. When two files conflict, the more specific one wins. An edit takes effect on the next Turn. The instructions are capped at 64 KiB in all; past that, Vibey is told which file was cut or left out.+`AGENTS.override.md` takes the place of a directory's `AGENTS.md`. When two files conflict, the more specific one wins. Files in directories below the working directory are not loaded up front: Vibey is told to read a subtree's file before it works with files there. An edit takes effect on the next Turn. The instructions are capped at 64 KiB in all; past that, Vibey is told which file was cut or left out.The setup wizard detects Claude Code, Codex, and OpenCode on your machine and installs any you choose that are missing. To install one yourself:diff --git a/README_ZH.md b/README_ZH.mdindex d7ea1bab7..e223c66f4 100644--- a/README_ZH.md+++ b/README_ZH.md@@ -277,7 +277,7 @@ vibe vault # 管理密钥、请求、认证请求与签名1. `~/.avibe/AGENTS.md`,对所有项目生效;2. 再从文件系统根目录一路到工作目录,读每一层的 `AGENTS.md`(或 `CLAUDE.md`)。-`AGENTS.override.md` 会替代所在目录的 `AGENTS.md`。几份文件冲突时,越具体的那份为准。改了文件,下一个 Turn 就生效。这部分说明合计上限 64 KiB;超出时,Vibey 会被告知哪份被截断或没有加载。+`AGENTS.override.md` 会替代所在目录的 `AGENTS.md`。几份文件冲突时,越具体的那份为准。工作目录下面子目录里的说明文件不会预先加载:Vibey 会被告知,处理某个子目录里的文件前,先读那个子目录的说明文件。改了文件,下一个 Turn 就生效。这部分说明合计上限 64 KiB;超出时,Vibey 会被告知哪份被截断或没有加载。设置向导会检测你机器上的 Claude Code、Codex 和 OpenCode,缺哪个、你选了哪个,就帮你装上。想自己装的话:diff --git a/docs/plans/agent-core-contracts/tools.md b/docs/plans/agent-core-contracts/tools.mdindex e23f0e1f8..823fea2ee 100644--- a/docs/plans/agent-core-contracts/tools.md+++ b/docs/plans/agent-core-contracts/tools.md@@ -398,6 +398,7 @@ tools, guidelines) and before Avibe's injected sections:<project_context>Project-specific instructions and guidelines:More general files come first; where two conflict, the later, more specific one wins.+A directory below the working directory may hold its own instruction file with more specific rules for that subtree: the first readable one of AGENTS.override.md, AGENTS.md, AGENTS.MD, CLAUDE.md, CLAUDE.MD in that directory, and only that one. Read it before working with files there.<project_instructions path="/Users/me/.avibe/AGENTS.md">...@@ -409,14 +410,19 @@ More general files come first; where two conflict, the later, more specific one</project_context>```-- The first line is Pi's. The second is Avibe's.+- The first line is Pi's. The second and third are Avibe's.+- Files below the cwd are not loaded. As Codex does in its prompt, the third line tells the Agent that a subtree may+ hold its own file and to read it before working with files there. It states the loader's own rule for each+ directory above: the candidates in their order, and only the first readable one counts.+ - The line is constant, so it keeps the section cache-stable.+ - It appears even when no file was loaded, since a subtree may still hold one. The section is then that line alone:+ `<project_context>`, the line, `</project_context>`.- Each path is escaped (see Bound below) and never cut.- Three reasons for the place:- It is Pi's order: rules, then project context, then skills.- The head and these files are the same for every Session in that cwd, while Avibe's sections carry the Session'sown facts, so the provider's cache shares the longer prefix across Sessions.- The Agent's own definition, in Avibe's sections, is more specific than a repository's guidance, and comes later.-- With no file to load, the section is absent.**Read every Turn, cache-stable.** The files are read again at the start of every Turn, from that Turn's cwd, so anedit takes effect on the next Turn. The section depends only on the files' paths and contents, never on times or@@ -444,4 +450,4 @@ file) is about 31 KB, so Codex's 32 KiB default would already cut it.- A file is loaded once per real path, not once per path string.- A blank file is left out.- An unreadable file is skipped silently. Pi warns on stderr, which the Agent has no place to show.-- The precedence line.+- The precedence line, and the line about files below the cwd (Codex's approach).diff --git a/modules/agents/vibey/instructions.py b/modules/agents/vibey/instructions.pyindex 175fa5029..08166e81d 100644--- a/modules/agents/vibey/instructions.py+++ b/modules/agents/vibey/instructions.py@@ -27,6 +27,14 @@ LIMIT = 65_536OMITTED_ROOM = 1_024HEADER = "Project-specific instructions and guidelines:"PRECEDENCE = "More general files come first; where two conflict, the later, more specific one wins."+#: Files below the cwd are never loaded; as Codex does, the section tells the Agent to look for them. It states the+#: loader's rule for each directory above, built from ``CANDIDATES`` so the two cannot drift. Constant, and present+#: even when no file loaded, since a subtree may still hold one.+SUBTREE = (+ "A directory below the working directory may hold its own instruction file with more specific rules for that "+ f"subtree: the first readable one of {', '.join(CANDIDATES)} in that directory, and only that one. Read it before "+ "working with files there."+)TRUNCATED = ("[Truncated: the first {shown} of {size} bytes. The instruction files share a 65,536-byte limit; read the file ""for the rest.]"@@ -196,14 +204,14 @@ def _not_loaded(files: Sequence[InstructionFile]) -> str:def project_context(files: Sequence[InstructionFile]) -> str:- """The ``<project_context>`` section, or "" with no file; at most ``LIMIT`` bytes, all of it counted.+ """The ``<project_context>`` section, at most ``LIMIT`` bytes, all of it counted; with no file, only ``SUBTREE``.The room goes first to the global file, then to the files from the cwd upward, so the most specific one is the lastcut. A file that gets no room is named in the closing notice. The section keeps the files' order either way."""if not files:- return ""- opening, closing = f"<project_context>\n{HEADER}\n{PRECEDENCE}", "\n</project_context>"+ return f"<project_context>\n{SUBTREE}\n</project_context>"+ opening, closing = f"<project_context>\n{HEADER}\n{PRECEDENCE}\n{SUBTREE}", "\n</project_context>"left = LIMIT - _bytes(opening) - _bytes(closing) - OMITTED_ROOMfirst = [index for index, file in enumerate(files) if file.is_global]rest = [index for index in reversed(range(len(files))) if not files[index].is_global]diff --git a/tests/test_vibey_agent.py b/tests/test_vibey_agent.pyindex 43d778fd8..b5b93ce89 100644--- a/tests/test_vibey_agent.py+++ b/tests/test_vibey_agent.py@@ -1788,15 +1788,23 @@ async def test_the_instruction_files_enter_between_the_head_and_avibes_sections_without, first, again, edited = (request.system for request in harness.provider.requests)# The section's text, stated here rather than built by the code under test.+ subtree = (+ "A directory below the working directory may hold its own instruction file with more specific rules for that "+ "subtree: the first readable one of AGENTS.override.md, AGENTS.md, AGENTS.MD, CLAUDE.md, CLAUDE.MD in that "+ "directory, and only that one. Read it before working with files there."+ )section = ("<project_context>\nProject-specific instructions and guidelines:\n"- "More general files come first; where two conflict, the later, more specific one wins.\n\n"+ f"More general files come first; where two conflict, the later, more specific one wins.\n{subtree}\n\n"f'<project_instructions path="{global_path}">\nReport in Chinese.\n</project_instructions>\n\n'f'<project_instructions path="{tmp_path / "AGENTS.md"}">\nRun tests under the sandbox.\n'"</project_instructions>\n</project_context>")+ # With no file, the section holds only the rule to look below the cwd.head_end = without.index(FINAL_REPLY_RULE) + len(FINAL_REPLY_RULE)- assert first == f"{without[:head_end]}\n\n{section}{without[head_end:]}"+ empty = f"\n\n<project_context>\n{subtree}\n</project_context>"+ assert without[head_end:].startswith(empty)+ assert first == f"{without[:head_end]}\n\n{section}{without[head_end + len(empty):]}"assert again == firstassert edited != first and "Never push to master." in editeddiff --git a/tests/test_vibey_project_instructions.py b/tests/test_vibey_project_instructions.pyindex 4ef339f2c..1905594ad 100644--- a/tests/test_vibey_project_instructions.py+++ b/tests/test_vibey_project_instructions.py@@ -15,9 +15,14 @@ import pytestfrom modules.agents.vibey.instructions import InstructionFile, load_instruction_files, project_context# The model-facing text, stated here rather than read from the constants it checks (C-7 tools.md section 9).+SUBTREE = (+ "A directory below the working directory may hold its own instruction file with more specific rules for that "+ "subtree: the first readable one of AGENTS.override.md, AGENTS.md, AGENTS.MD, CLAUDE.md, CLAUDE.MD in that "+ "directory, and only that one. Read it before working with files there."+)HEADER = ("Project-specific instructions and guidelines:\n"- "More general files come first; where two conflict, the later, more specific one wins."+ f"More general files come first; where two conflict, the later, more specific one wins.\n{SUBTREE}")@@ -166,7 +171,8 @@ def test_the_section_holds_each_file_by_path_in_order() -> None:'<project_instructions path="/src/\\u003ca \\u0022b\\u0022 \\u0026 c\\u003e/AGENTS.md">\nproject rules\n'"</project_instructions>\n</project_context>")- assert project_context([]) == ""+ # Files below the cwd are never loaded, so the rule to look for them stands even when no file loaded.+ assert project_context([]) == f"<project_context>\n{SUBTREE}\n</project_context>"_NOTICE = re.compile(