"""Text shared by the installer, the MCP server and restart prompts: how hosts run Harbor and the team protocol.""" import shutil import sys from .projects import PACKAGE_ROOT def launcher(python=None): """The command prefix hosts run: forward slashes and no quotes, so cmd, PowerShell and bash all accept it.""" run = (PACKAGE_ROOT / "run.py").as_posix() if python: return python.split() + ["-B", run] if shutil.which("py"): return ["py", f"-{sys.version_info.major}.{sys.version_info.minor}", "-B", run] return [sys.executable.replace("\\", "/"), "-B", run] def protocol(agent, project_name=None, cmd=None): """The rules every agent follows, in the second person, as a markdown section.""" run = " ".join(cmd or launcher()) scope = (f"in the Harbor project `{project_name}`" if project_name else "inside a Harbor project (a `.harbor.toml` file exists in your working folder or a parent folder)") return f"""## Team coordination (Harbor) When you work {scope}, you are **{agent}** on a team coordinated through Harbor (MCP tools named `brief`, `send`, ..., or the command `{run} --as {agent} `): - Start every session with `brief`. If it reports a STOP for you, do not start or continue work; only the human can resume. If the brief shows a handoff you wrote earlier, continue from it. - Take work with `next` (the highest-priority task you may do) instead of waiting to be told. Mark it done, or `submit` the commit to the review queue with the task number; landing closes the task. - Keep `doing` current: one line the whole team sees. Do not post progress reports to everyone. - Talk in threads named after the subject (fn:0x..., commit:..., task:N, item:N) and answer with `reply`. Write plain sentences; never run words and numbers together. A correction uses `--corrects `. - Acknowledge with `ack` (and a short note) instead of sending "received". Ask for an acknowledgement, or set a due time, only when you need the answer. - Claim before you work on something that is not a task (`claim fn:0x...`); release when done. - Before you start on a function or file, read `context `: notes, earlier threads and review items about it. Record what you learn that others will need (an ABI detail, a trap, a decision) with `note "..."`. - Before asking the team about a function, `who ` tells you who has worked on it. When a thread grows long, write a short `summarize "..."` (decided, open, who does what next). - When you need the human to decide, use `ask` with short options ("Yes", "No", "Later"); they answer with one tap. Never post a bare question to everyone and wait. - When you wait on someone, use `wait_for_messages` (`wait`) instead of sleeping or polling. - Before your session ends or your allowance runs out, write a `handoff`: what you finished, what is in flight, what comes next. It is shown to you (and the team) at the start of the next session. """