python-agent-harness 1.5.6.9__py3-none-any.whl → 1.5.7.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ from .mcp.config import MCPConfig, MCPServerConfig
7
7
  from .mcp.manager import MCPManager
8
8
  from .session.session import Session
9
9
 
10
- __version__ = "1.5.6.9"
10
+ __version__ = "1.5.7.2"
11
11
 
12
12
  __all__ = [
13
13
  "Client",
@@ -8,7 +8,7 @@ Commands:
8
8
  runs repeatedly, answer mid-run questions, cancel
9
9
  config [--init] show effective LLM config / write a template file
10
10
 
11
- Custom commands (prompts/commands/*.md) — like init, review,
11
+ Custom commands (prompts/commands/*.md, or paths.command_path) — like init, review,
12
12
  sessions, restore and summary/explain — are TUI slash commands only;
13
13
  they are NOT registered as CLI subcommands.
14
14
 
@@ -136,6 +136,8 @@ def make_session(
136
136
  registry=registry,
137
137
  context_path=paths.get("context_path"),
138
138
  skill_path=paths.get("skill_path"),
139
+ agent_path=paths.get("agent_path"),
140
+ command_path=paths.get("command_path"),
139
141
  mcp=mcp_config,
140
142
  model_profiles=model_profiles,
141
143
  default_agent=default_agent,
@@ -305,6 +307,8 @@ def cmd_config(args: argparse.Namespace) -> int:
305
307
  print(f"timeout: {settings['timeout']}")
306
308
  print(f"context_path: {paths['context_path'] or '(default: <project>/contexts)'}")
307
309
  print(f"skill_path: {paths['skill_path'] or '(default: <project>/skills)'}")
310
+ print(f"agent_path: {paths['agent_path'] or '(unset: bundled prompts/agents only)'}")
311
+ print(f"command_path: {paths['command_path'] or '(unset: bundled prompts/commands only)'}")
308
312
  if mcp_config.servers:
309
313
  for name, server in mcp_config.servers.items():
310
314
  status = "enabled" if server.enabled else "disabled"
@@ -24,10 +24,10 @@ from typing import Any
24
24
 
25
25
  from ..core.agent import run_agent_loop
26
26
  from ..core.models import ImagePart, Message, TextPart, api_safe
27
- from ..hooks import RunStatus
28
27
  from ..io.attachments import AttachmentError, parse_at_references
29
28
  from ..io.text_filter import strip_final_check
30
29
  from ..session import config
30
+ from ..session.hooks import RunStatus
31
31
  from ..session.session import Session
32
32
  from .view import View
33
33
 
@@ -211,6 +211,14 @@ class Controller:
211
211
  def configured_context_path(self) -> str | None:
212
212
  return self.session._configured_context_path
213
213
 
214
+ @property
215
+ def configured_agent_path(self) -> str | None:
216
+ return self.session._configured_agent_path
217
+
218
+ @property
219
+ def configured_command_path(self) -> str | None:
220
+ return self.session._configured_command_path
221
+
214
222
  @property
215
223
  def startup_warnings(self) -> list[str]:
216
224
  return self.session.startup_warnings
@@ -1000,8 +1000,14 @@ class Client:
1000
1000
  {"id": "", "name": "", "arguments": ""},
1001
1001
  )
1002
1002
  fn = tc.get("function") or {}
1003
- entry["id"] += tc.get("id") or ""
1004
- entry["name"] += fn.get("name") or ""
1003
+ # id/name are not incremental like arguments: some backends and
1004
+ # proxies resend them in EVERY chunk, and appending blindly made
1005
+ # "ReadRead" (an unknown tool) out of a repeated "Read". A piece
1006
+ # equal to what is already accumulated is such a repeat and is
1007
+ # skipped; a genuinely split value ("Re" + "ad") still appends.
1008
+ for key, piece in (("id", tc.get("id")), ("name", fn.get("name"))):
1009
+ if isinstance(piece, str) and piece and piece != entry[key]:
1010
+ entry[key] += piece
1005
1011
  frag = fn.get("arguments") or ""
1006
1012
  if isinstance(frag, dict):
1007
1013
  frag = json.dumps(frag, ensure_ascii=False)
@@ -24,6 +24,7 @@ over this.
24
24
 
25
25
  from __future__ import annotations
26
26
 
27
+ import math
27
28
  from collections.abc import Mapping
28
29
  from dataclasses import dataclass, field
29
30
  from typing import Any
@@ -69,6 +70,17 @@ class MCPServerConfig:
69
70
  raise ValueError(f"MCP server {label!r}: stdio transport requires `command`")
70
71
  elif not self.url:
71
72
  raise ValueError(f"MCP server {label!r}: {self.transport} transport requires `url`")
73
+ # timeout flows into ``time.monotonic() + timeout`` and the SDK's
74
+ # read timeout; a string/bool/non-finite value from the JSON config
75
+ # would otherwise only fail mid-run with an opaque TypeError.
76
+ # bool is excluded explicitly because it is an int subclass.
77
+ t = self.timeout
78
+ if t is not None and (
79
+ isinstance(t, bool) or not isinstance(t, (int, float)) or not math.isfinite(t) or t <= 0
80
+ ):
81
+ raise ValueError(
82
+ f"MCP server {label!r}: `timeout` must be a positive number of seconds, got {t!r}"
83
+ )
72
84
 
73
85
 
74
86
  @dataclass
@@ -31,8 +31,15 @@ RESERVED_AGENT_NAME = "default"
31
31
 
32
32
 
33
33
  def read_prompt_file(name: str) -> str:
34
- """Read a prompt file from the package prompts dir."""
35
- path = PROMPTS_DIR / name
34
+ """Read a prompt file.
35
+
36
+ ``name`` is either relative to the packaged prompts directory or an
37
+ absolute path (a custom command configured outside the package, see
38
+ ``paths.command_path``).
39
+ """
40
+ path = Path(os.path.expanduser(name))
41
+ if not path.is_absolute():
42
+ path = PROMPTS_DIR / path
36
43
  return path.read_text(encoding="utf-8")
37
44
 
38
45
 
@@ -621,8 +628,10 @@ def compacted_messages(summary: str, prompts: list[str], resume: bool = False) -
621
628
 
622
629
 
623
630
  # ---- custom agent discovery -----------------------------------------------
624
- # Agent prompt files are markdown files (``*.md``) in
625
- # ``prompts/agents/``. Each file becomes a switchable agent profile
631
+ # Agent prompt files are markdown files (``*.md``) in the bundled
632
+ # ``prompts/agents/`` directory and, when configured, in
633
+ # ``paths.agent_path`` too (configured names override bundled ones).
634
+ # Each file becomes a switchable agent profile
626
635
  # available via the ``/agent`` TUI command. The file's stem (e.g.
627
636
  # ``reviewer.md`` → ``reviewer``) is the agent name; an optional YAML
628
637
  # frontmatter ``name:`` can override it, and an optional
@@ -630,7 +639,7 @@ def compacted_messages(summary: str, prompts: list[str], resume: bool = False) -
630
639
  # entry matches by exact name, glob pattern, or ``__``-delimited
631
640
  # prefix, e.g. ``mcp__git`` or ``mcp__git__*``). The built-in
632
641
  # ``default`` agent (``prompts/agent.md``) is always available and
633
- # cannot be overridden by a file in this directory.
642
+ # cannot be overridden by a file in these directories.
634
643
 
635
644
 
636
645
  def _agent_frontmatter(path: Path) -> dict[str, Any]:
@@ -697,21 +706,40 @@ def agent_exclude_tools(path: Path | str) -> tuple[str, ...]:
697
706
  return tuple(_agent_frontmatter(Path(path)).get("exclude_tools", ()))
698
707
 
699
708
 
700
- def discover_agents() -> dict[str, str]:
701
- """Discover all custom agents in the ``prompts/agents/`` directory.
702
-
703
- Returns a dict mapping agent name → absolute path to the prompt
704
- file. Files without a valid name are skipped. The built-in
705
- ``default`` agent is NOT included here — callers add it separately.
706
- A file claiming the reserved name ``default`` (via stem or
707
- frontmatter) is skipped: the built-in agent always wins.
709
+ def _scan_agents_dir(directory: Path) -> dict[str, str]:
710
+ """Map agent name → resolved prompt path for the ``*.md`` files in
711
+ *directory*. Files without a valid name are skipped, as is a file
712
+ claiming the reserved name ``default``. A missing directory yields
713
+ an empty dict.
708
714
  """
709
- if not AGENTS_DIR.is_dir():
715
+ if not directory.is_dir():
710
716
  return {}
711
717
  agents: dict[str, str] = {}
712
- for f in sorted(AGENTS_DIR.glob("*.md")):
718
+ for f in sorted(directory.glob("*.md")):
713
719
  name = _agent_name_from_file(f)
714
720
  if not name or name == RESERVED_AGENT_NAME:
715
721
  continue
716
722
  agents[name] = str(f.resolve())
717
723
  return agents
724
+
725
+
726
+ def discover_agents(agents_dir: str | os.PathLike | None = None) -> dict[str, str]:
727
+ """Discover custom agents from the bundled and the configured directory.
728
+
729
+ Returns a dict mapping agent name → absolute path to the prompt
730
+ file. Files without a valid name are skipped. The built-in
731
+ ``default`` agent is NOT included here — callers add it separately.
732
+ A file claiming the reserved name ``default`` (via stem or
733
+ frontmatter) is skipped: the built-in agent always wins.
734
+
735
+ The bundled ``prompts/agents/`` profiles are always discovered. When
736
+ *agents_dir* is set (``paths.agent_path`` in the config file), its
737
+ files are layered on top: a configured agent overrides a bundled one
738
+ of the same name, and the rest of the bundled profiles stay
739
+ available. A missing configured directory contributes nothing.
740
+ """
741
+ agents = _scan_agents_dir(AGENTS_DIR)
742
+ if agents_dir:
743
+ configured = Path(os.path.abspath(os.path.expanduser(agents_dir)))
744
+ agents.update(_scan_agents_dir(configured))
745
+ return agents
@@ -9,24 +9,44 @@ the run's user text.
9
9
  Tool availability per command:
10
10
  - init/review: all tools EXCEPT PlanExit (they are one-shot runs that
11
11
  must not end in a plan/build handoff)
12
- - custom commands (prompts/commands/*.md): all tools, incl. PlanExit
12
+ - custom commands (prompts/commands/*.md and paths.command_path): all tools, incl. PlanExit
13
13
  - compact/summary: no tools at all (direct chat_sync calls, like the
14
14
  session-title generation)
15
+
16
+ Precedence: a command file (configured dir first, then bundled) replaces
17
+ the builtin slash command of the same name — see ``find_command``.
15
18
  """
16
19
 
17
20
  from __future__ import annotations
18
21
 
22
+ import os
19
23
  import re
20
- import subprocess
21
24
  from collections.abc import Callable
22
25
  from pathlib import Path
23
26
  from typing import Any
24
27
 
25
- from ..prompts import read_prompt_file
28
+ from ..prompts import _git_toplevel, read_prompt_file
26
29
 
27
30
  PROMPTS_DIR = Path(__file__).parents[1] / "prompts"
28
31
  COMMANDS_DIR = PROMPTS_DIR / "commands"
29
32
 
33
+ # Custom command files take precedence over the builtin slash commands (see
34
+ # ``find_command``), so a configured ``review.md`` replaces ``/review``. The
35
+ # one exception is ``/exit``: it is the only way out of an interactive
36
+ # session, so a command file may not shadow it. Such a file is skipped and
37
+ # ``/help`` reports it instead of silently dropping it.
38
+ UNOVERRIDABLE_COMMAND_NAMES = frozenset({"exit"})
39
+
40
+
41
+ def _prompt_file_ref(f: Path) -> str:
42
+ """Reference for ``read_prompt_file``: relative to the packaged prompts
43
+ dir when the file lives inside it (backward compatible), absolute
44
+ otherwise (a custom command dir configured via ``paths.command_path``)."""
45
+ try:
46
+ return str(f.relative_to(PROMPTS_DIR))
47
+ except ValueError:
48
+ return os.path.abspath(f)
49
+
30
50
 
31
51
  def _substitute(text: str, path: str, extra: str | None) -> str:
32
52
  text = text.replace("${path}", path)
@@ -35,22 +55,19 @@ def _substitute(text: str, path: str, extra: str | None) -> str:
35
55
 
36
56
 
37
57
  def _project_root(cwd: str) -> str:
38
- """Best-effort project root (git dir or parent with AGENTS.md)."""
58
+ """Best-effort project root (git worktree root, else parent with AGENTS.md).
59
+
60
+ Inside a git repository this delegates to ``prompts.core._git_toplevel``
61
+ so slash commands and project-context loading agree on the root.
62
+ Outside a repository the nearest ancestor holding ``AGENTS.md`` wins,
63
+ else *cwd* itself.
64
+ """
39
65
  d = Path(cwd).resolve()
40
- try:
41
- out = subprocess.run(
42
- ["git", "rev-parse", "--show-toplevel"],
43
- cwd=cwd,
44
- capture_output=True,
45
- text=True,
46
- timeout=10,
47
- )
48
- if out.returncode == 0 and out.stdout.strip():
49
- return out.stdout.strip()
50
- except (OSError, subprocess.TimeoutExpired):
51
- pass
52
- for parent in [d, *d.parents]:
53
- if (parent / "AGENTS.md").exists() or (parent / ".git").exists():
66
+ ancestors = [d, *d.parents]
67
+ if any((p / ".git").exists() for p in ancestors):
68
+ return _git_toplevel(cwd)
69
+ for parent in ancestors:
70
+ if (parent / "AGENTS.md").exists():
54
71
  return str(parent)
55
72
  return cwd
56
73
 
@@ -84,7 +101,7 @@ class SessionCommand:
84
101
  Used by the TUI slash commands, which run inside the current
85
102
  session.
86
103
  """
87
- cwd = project_dir or _project_root(__import__("os").getcwd())
104
+ cwd = project_dir or _project_root(os.getcwd())
88
105
  prompt = _substitute(read_prompt_file(self.prompt_file), cwd, extra)
89
106
  kickoff = self.kickoff
90
107
  if "${path}" in kickoff:
@@ -144,18 +161,32 @@ def custom_name(file: str) -> str:
144
161
  return base.strip("-")
145
162
 
146
163
 
147
- def load_custom_commands() -> list[SessionCommand]:
148
- if not COMMANDS_DIR.is_dir():
164
+ def _resolve_commands_dir(commands_dir: str | os.PathLike | None) -> Path | None:
165
+ """Absolute path of a configured commands dir, or None when unset."""
166
+ if not commands_dir:
167
+ return None
168
+ return Path(os.path.abspath(os.path.expanduser(commands_dir)))
169
+
170
+
171
+ def _scan_commands_dir(directory: Path) -> list[SessionCommand]:
172
+ """Commands defined by the ``*.md`` files in *directory*.
173
+
174
+ Files whose name normalizes to nothing (``---.md``) and files that
175
+ would shadow an unoverridable builtin (see
176
+ ``UNOVERRIDABLE_COMMAND_NAMES``) are skipped, so the advertised
177
+ listing only contains runnable commands.
178
+ """
179
+ if not directory.is_dir():
149
180
  return []
150
181
  commands = []
151
- for f in sorted(COMMANDS_DIR.glob("*.md")):
182
+ for f in sorted(directory.glob("*.md")):
152
183
  name = custom_name(f.name)
153
- if not name:
184
+ if not name or name in UNOVERRIDABLE_COMMAND_NAMES:
154
185
  continue
155
186
  commands.append(
156
187
  SessionCommand(
157
188
  name=name,
158
- prompt_file=str(f.relative_to(PROMPTS_DIR)),
189
+ prompt_file=_prompt_file_ref(f),
159
190
  kickoff="Proceed with the task described in your instructions.\n",
160
191
  status=f" Running {name}...",
161
192
  )
@@ -163,13 +194,55 @@ def load_custom_commands() -> list[SessionCommand]:
163
194
  return commands
164
195
 
165
196
 
166
- def find_command(name: str) -> SessionCommand | None:
167
- """Look up a command by name: builtins (init/review) then custom."""
197
+ def unoverridable_command_names(commands_dir: str | os.PathLike | None = None) -> list[str]:
198
+ """Names in *commands_dir* skipped because the builtin cannot be replaced.
199
+
200
+ Only ``exit`` is in that set; ``/help`` reports the files so the user
201
+ is not left wondering why their command never ran.
202
+ """
203
+ directory = _resolve_commands_dir(commands_dir)
204
+ if directory is None or not directory.is_dir():
205
+ return []
206
+ return sorted(
207
+ name
208
+ for name in (custom_name(f.name) for f in sorted(directory.glob("*.md")))
209
+ if name in UNOVERRIDABLE_COMMAND_NAMES
210
+ )
211
+
212
+
213
+ def load_custom_commands(
214
+ commands_dir: str | os.PathLike | None = None,
215
+ ) -> list[SessionCommand]:
216
+ """Load custom commands from the bundled and the configured directory.
217
+
218
+ The bundled ``prompts/commands/`` commands are always loaded. When
219
+ *commands_dir* is set (``paths.command_path`` in the config file),
220
+ its files are layered on top: a configured command overrides a
221
+ bundled one of the same name, and the remaining bundled commands stay
222
+ available. A missing configured directory contributes nothing.
223
+ """
224
+ merged = {c.name: c for c in _scan_commands_dir(COMMANDS_DIR)}
225
+ configured = _resolve_commands_dir(commands_dir)
226
+ if configured is not None:
227
+ merged.update({c.name: c for c in _scan_commands_dir(configured)})
228
+ return [merged[name] for name in sorted(merged)]
229
+
230
+
231
+ def find_command(name: str, commands_dir: str | os.PathLike | None = None) -> SessionCommand | None:
232
+ """Look up a command by name.
233
+
234
+ Command files win over the builtin prompt commands, so a configured
235
+ ``review.md`` replaces ``/review`` and an ``init.md`` replaces
236
+ ``/init``. Among command files the configured directory wins over
237
+ the bundled one (see ``load_custom_commands``); the remaining bundled
238
+ ``initialize.md``/``review.md`` prompts back the builtins when no
239
+ command file claims the name.
240
+ """
241
+ for c in load_custom_commands(commands_dir):
242
+ if c.name == name:
243
+ return c
168
244
  if name == "init":
169
245
  return initialize_command()
170
246
  if name == "review":
171
247
  return review_command()
172
- for c in load_custom_commands():
173
- if c.name == name:
174
- return c
175
248
  return None
@@ -244,6 +244,8 @@ DEFAULT_LLM: dict = {
244
244
  DEFAULT_PATHS: dict = {
245
245
  "context_path": None,
246
246
  "skill_path": None,
247
+ "agent_path": None,
248
+ "command_path": None,
247
249
  }
248
250
 
249
251
  # Sub-agent LLM overrides: every key defaults to None, meaning "inherit
@@ -319,9 +321,11 @@ CONFIG_TEMPLATE = """\
319
321
  "env_passthrough": []
320
322
  }},
321
323
  "paths": {{
322
- "_comment": "Optional overrides for context and skill directories. Absolute paths or ~ expansion supported.",
324
+ "_comment": "Optional overrides for context files, skills, custom agents, and custom commands. Absolute paths or ~ expansion supported. context_path/skill_path replace the project-local default; agent_path/command_path are merged on top of the bundled prompts/ directories, where a same-named configured file wins.",
323
325
  "context_path": null,
324
- "skill_path": null
326
+ "skill_path": null,
327
+ "agent_path": null,
328
+ "command_path": null
325
329
  }},
326
330
  "hooks": {{
327
331
  "_comment": "Optional shell-command hooks (see README 'Hooks'). Events: tool.before, tool.after, agent.start, agent.end; each a list of {{command, matcher?, timeout?, fail_closed?, env_passthrough?}}. A command runs via /bin/sh -c in the project dir with the event as JSON on stdin. Exit 2 = tool.before: block the call (stderr = reason); tool.after: stderr is feedback appended to the result. agent.start: stdout (exit 0) is context for the turn. agent.end: notification. The payload is model-written (untrusted): never eval it. Secret-looking env vars are removed unless listed in env_passthrough. Keys starting with _ are ignored: copy entries from _examples to enable them.",
@@ -561,9 +565,11 @@ def load_serve_limits(path: str | os.PathLike | None = None) -> tuple[int | None
561
565
  def load_paths_config(path: str | os.PathLike | None = None) -> dict:
562
566
  """Load paths settings from the config file.
563
567
 
564
- Returns a dict with ``context_path`` and ``skill_path`` keys.
565
- Values are expanded (~ → home) and resolved to absolute paths when
566
- set; None means "use default discovery logic".
568
+ Returns a dict with ``context_path``, ``skill_path``, ``agent_path``,
569
+ and ``command_path`` keys. Values are expanded (~ → home) and resolved
570
+ to absolute paths when set; None means "use default discovery logic"
571
+ (for ``agent_path``/``command_path``: the bundled ``prompts/``
572
+ directories only, since those are merged rather than replaced).
567
573
  """
568
574
  settings = dict(DEFAULT_PATHS)
569
575
  try:
@@ -573,7 +579,7 @@ def load_paths_config(path: str | os.PathLike | None = None) -> dict:
573
579
  paths = data.get("paths") or {}
574
580
  if not isinstance(paths, dict):
575
581
  return settings
576
- for key in ("context_path", "skill_path"):
582
+ for key in ("context_path", "skill_path", "agent_path", "command_path"):
577
583
  val = paths.get(key)
578
584
  if isinstance(val, str) and val.strip():
579
585
  settings[key] = os.path.abspath(os.path.expanduser(val.strip()))
@@ -608,7 +614,7 @@ def load_hooks(path: str | os.PathLike | None = None) -> list:
608
614
  file or a malformed entry raises ValueError, so a configured guard
609
615
  stops the session instead of being silently dropped.
610
616
  """
611
- from ..hooks import parse_hooks # lazy: keep config import-light
617
+ from .hooks import parse_hooks # lazy: keep config import-light
612
618
 
613
619
  section = _read_config(path).get("hooks")
614
620
  try:
@@ -317,7 +317,7 @@ def _stop(proc: subprocess.Popen[bytes], readers: list[threading.Thread]) -> Non
317
317
  def _env_builder() -> Callable[[Hook], dict[str, str]]:
318
318
  """Per-event environment: os.environ snapshotted and scrubbed ONCE
319
319
  (the scrub can stat paths), then each hook's passthrough added back."""
320
- from .tools.bash import scrubbed_env # lazy: avoids an import cycle
320
+ from ..tools.bash import scrubbed_env # lazy: avoids an import cycle
321
321
 
322
322
  full = dict(os.environ)
323
323
  base = scrubbed_env(full)
@@ -19,7 +19,6 @@ from ..core.models import AgentMode, ImagePart
19
19
  from ..core.planmode import PlanMode
20
20
  from ..core.subagent import run_subagent
21
21
  from ..core.token_estimator import TokenCalibrator
22
- from ..hooks import HookRunner
23
22
  from ..io.attachments import image_placeholder
24
23
  from ..io.diffrender import sanitize_for_display
25
24
  from ..io.persistence import SessionPersistence, escape_role_headers
@@ -32,6 +31,7 @@ from ..tools import Registry, ToolContext
32
31
  from ..tools.base import PendingToolResult, resolve_path
33
32
  from ..tools.filesystem import cleanup_spooled_files
34
33
  from ..tools.mcp import mcp_tools_from_manager
34
+ from .hooks import HookRunner
35
35
 
36
36
  if TYPE_CHECKING:
37
37
  from ..tools.base import ToolRuntime
@@ -94,6 +94,8 @@ class Session:
94
94
  registry: Registry | None = None,
95
95
  context_path: str | None = None,
96
96
  skill_path: str | None = None,
97
+ agent_path: str | None = None,
98
+ command_path: str | None = None,
97
99
  mcp: MCPConfig | None = None,
98
100
  mcp_manager: MCPManager | None = None,
99
101
  model_profiles: dict[str, dict] | None = None,
@@ -115,6 +117,11 @@ class Session:
115
117
  self.alive = True
116
118
  self._configured_context_path = context_path
117
119
  self._configured_skill_path = skill_path
120
+ # Custom agent / command directories (paths.agent_path and
121
+ # paths.command_path in the config file); None = the bundled
122
+ # prompts/agents and prompts/commands directories.
123
+ self._configured_agent_path = agent_path
124
+ self._configured_command_path = command_path
118
125
  # Config file path (None = default resolution) — /model re-reads
119
126
  # the ``models`` section from it on every invocation
120
127
  self.config_path = config_path
@@ -252,7 +259,7 @@ class Session:
252
259
  self.notify_fn: Callable[[str, Any], None] | None = None
253
260
  self.confirm_fn: Callable[[str], bool] | None = None
254
261
  self.ask_fn: Callable[[list[dict]], str] | None = None
255
- # shell-command hooks (see hooks.py); none until the entry point
262
+ # shell-command hooks (see session/hooks.py); none until the entry point
256
263
  # installs the configured ones (cli.make_session)
257
264
  self.install_hooks([])
258
265
  # Per-thread run identity for event emission, tagged by
@@ -262,7 +269,7 @@ class Session:
262
269
  self._emit_local = threading.local()
263
270
 
264
271
  # ------------------------------------------------------------------
265
- # shell-command hooks (see hooks.py)
272
+ # shell-command hooks (see session/hooks.py)
266
273
  # ------------------------------------------------------------------
267
274
  def install_hooks(self, hooks: list) -> None:
268
275
  """Replace the session's hooks with HOOKS (a list of ``hooks.Hook``).
@@ -970,8 +977,10 @@ class Session:
970
977
  def switch_agent(self, name: str) -> tuple[bool, str]:
971
978
  """Switch the main agent's system prompt to a named agent.
972
979
 
973
- Agent prompt files are discovered from the ``prompts/agents/`` package
974
- directory (see ``python_agent_harness.prompts.discover_agents``).
980
+ Agent prompt files are discovered from the bundled
981
+ ``prompts/agents/`` directory plus the configured agents directory
982
+ (``paths.agent_path``, whose files override bundled names); see
983
+ ``python_agent_harness.prompts.discover_agents``.
975
984
  The pseudo-name ``default`` restores the original system prompt
976
985
  saved at session construction. Returns (success, message).
977
986
  """
@@ -982,7 +991,7 @@ class Session:
982
991
  self._agent_excluded_tools = ()
983
992
  return True, "switched to default agent"
984
993
 
985
- agents = discover_agents()
994
+ agents = discover_agents(self._configured_agent_path)
986
995
  prompt_file = agents.get(name)
987
996
  if prompt_file is None:
988
997
  available = ", ".join(sorted([RESERVED_AGENT_NAME, *agents.keys()]))
@@ -37,6 +37,7 @@ import os
37
37
  import shutil # noqa: F401 (mock target for tests)
38
38
  import stat
39
39
  import subprocess # noqa: F401 (mock target for tests)
40
+ import sys
40
41
  import tempfile
41
42
  import threading
42
43
  import time
@@ -94,12 +95,26 @@ def _spool(text: str, label: str) -> str:
94
95
  suffix=".txt",
95
96
  dir=_spool_dir(),
96
97
  )
97
- with os.fdopen(fd, "w", encoding="utf-8") as f:
98
- f.write(text)
99
- with _spooled_files_lock:
100
- _spooled_files.append(temp_file)
101
98
  except OSError:
102
99
  return _truncate(text, label)
100
+ try:
101
+ with os.fdopen(fd, "w", encoding="utf-8") as f:
102
+ f.write(text)
103
+ except BaseException:
104
+ # The file exists on disk but was never tracked (tracking happens
105
+ # after a successful write), so cleanup_spooled_files could never
106
+ # remove it. Unlink before propagating to the in-memory fallback:
107
+ # a failed spool must not leave an orphan in TMPDIR — worst case a
108
+ # large, secret-bearing partial write surviving the session.
109
+ with contextlib.suppress(OSError):
110
+ os.unlink(temp_file)
111
+ if isinstance(sys.exc_info()[1], OSError):
112
+ # ordinary write failure (ENOSPC, quota, ...): fall back to
113
+ # in-memory truncation as before
114
+ return _truncate(text, label)
115
+ raise
116
+ with _spooled_files_lock:
117
+ _spooled_files.append(temp_file)
103
118
  lines = text.splitlines()
104
119
  preview = "\n".join(lines[:SPOOL_LINES])
105
120
  return (
@@ -35,7 +35,7 @@ class Grep(Tool):
35
35
 
36
36
  **How to use `Grep`:**
37
37
  - Supports full regex syntax (ripgrep-based)
38
- - Can specify directory path and glon to narrow scope
38
+ - Can specify directory path and glob to narrow scope
39
39
  - Use `context_lines` parameter to see surrounding lines
40
40
  - Can perform multiple focused grep searches in parallel
41
41
  """
@@ -19,7 +19,7 @@ from .filesystem import READ_SIZE_LIMIT, _spool
19
19
  class Read(Tool):
20
20
  name = "Read"
21
21
  is_readonly = True
22
- instructions = """\
22
+ instructions = f"""\
23
23
  **When to use `Read`:**
24
24
  - You need to examine file contents
25
25
  - Before editing any file (required)
@@ -32,10 +32,10 @@ class Read(Tool):
32
32
  - You want to use shell commands like cat → use `Read` instead
33
33
 
34
34
  **How to use `Read`:**
35
- - Default behavior reads up to 2000 lines from the beginning
36
- - For large files, use offset and limit parameters to read specific sections
37
- - Recommended to read the whole file by omitting offset/limit when possible
38
- - Always read beforing - the `Edit` tool will error otherwise
35
+ - Omitting `start_line`/`end_line` reads the whole file (files over {READ_SIZE_LIMIT // 1024} KB require a line range)
36
+ - For large files, use `start_line`/`end_line` to read specific sections
37
+ - Recommended to read the whole file by omitting `start_line`/`end_line` when possible
38
+ - Always read before editing - the `Edit` tool will error otherwise
39
39
  - Can read multiple files in parallel by making multiple `Read` calls
40
40
  """
41
41
  description = (
@@ -89,4 +89,5 @@ class Write(Tool):
89
89
  diff_text = unified_diff(old_content, content, path)
90
90
  if diff_text:
91
91
  ctx.record_diff(diff_text)
92
- return f"Created file {filename} in {dir_path}"
92
+ verb = "Overwrote" if existed else "Created"
93
+ return f"{verb} file {filename} in {dir_path}"
@@ -20,8 +20,6 @@ from rich.text import Text
20
20
 
21
21
  from ..core.models import ImagePart, Message, TextPart
22
22
  from ..entry.restore import (
23
- AGENT_KEY,
24
- MODEL_KEY,
25
23
  PROJECT_KEY,
26
24
  apply_saved_session,
27
25
  load_saved_session,
@@ -90,6 +88,14 @@ class CommandMixin:
90
88
  arg = arg.strip()
91
89
  if cmd == "/exit":
92
90
  return True
91
+ # A command file replaces the builtin slash command of the same
92
+ # name (configured directory first, then bundled), so /review,
93
+ # /plan, /help, ... can be redefined by a .md file. Nothing else
94
+ # reaches this branch: find_command returns None for a name no
95
+ # file claims and no builtin prompt command backs.
96
+ if find_command(cmd[1:], self._controller.configured_command_path) is not None:
97
+ self._run_slash_command(cmd[1:], arg)
98
+ return False
93
99
  if cmd == "/plan":
94
100
  self._controller.switch_to_plan()
95
101
  self.console.print(
@@ -105,8 +111,6 @@ class CommandMixin:
105
111
  self.console.print(f"saved: {safe_markup(path)}")
106
112
  elif cmd == "/summary":
107
113
  self._run_summary()
108
- elif cmd in ("/init", "/review") or find_command(cmd[1:]) is not None:
109
- self._run_slash_command(cmd[1:], arg)
110
114
  elif cmd == "/sessions":
111
115
  self._run_sessions()
112
116
  elif cmd == "/restore":
@@ -123,30 +127,58 @@ class CommandMixin:
123
127
  elif cmd == "/agent":
124
128
  self._run_agent_command(arg)
125
129
  elif cmd == "/help":
126
- from ..session.commands import load_custom_commands
127
-
128
- custom_names = {c.name for c in load_custom_commands()}
130
+ from ..session.commands import (
131
+ load_custom_commands,
132
+ unoverridable_command_names,
133
+ )
134
+ from .input import SLASH_COMMANDS
135
+
136
+ configured_dir = self._controller.configured_command_path
137
+ custom_names = {c.name for c in load_custom_commands(configured_dir)}
138
+ builtin_names = [c.lstrip("/") for c in SLASH_COMMANDS]
139
+ # A command file replaces the builtin of the same name, so that
140
+ # name is listed once (in the custom line) instead of twice.
141
+ builtin = " ".join(f"/{n}" for n in builtin_names if n not in custom_names)
129
142
  custom = " ".join(f"/{n}" for n in sorted(custom_names))
130
- builtin = "/plan /build /init /review /compact "
131
- builtin += "/save /summary /sessions /restore /clear /model /agent /exit"
132
- if custom:
133
- builtin += f"\n{custom}"
143
+ overridden = sorted(n for n in custom_names if n in set(builtin_names))
144
+ notes = ""
145
+ if overridden:
146
+ notes += "\noverrides builtin: " + ", ".join(f"{n}.md" for n in overridden)
147
+ unoverridable = unoverridable_command_names(configured_dir)
148
+ if unoverridable:
149
+ notes += "\nignored (cannot override): " + ", ".join(
150
+ f"{n}.md" for n in unoverridable
151
+ )
134
152
  explain_line = (
135
153
  "/explain [project] [target] explain code\n"
136
154
  if "explain" in custom_names
137
155
  else ""
138
156
  )
157
+ # A builtin replaced by a command file no longer has its own
158
+ # usage: the file's prompt takes the arguments now.
159
+ init_line = (
160
+ ""
161
+ if "init" in custom_names
162
+ else "/init [project] [--extra TEXT] create/update AGENTS.md\n"
163
+ )
164
+ review_line = (
165
+ ""
166
+ if "review" in custom_names
167
+ else "/review [project] [commit|branch|PR] review code changes\n"
168
+ )
139
169
  self.console.print(
140
- builtin + "\n"
141
- "/init [project] [--extra TEXT] create/update AGENTS.md\n"
142
- "/review [project] [commit|branch|PR] review code changes\n"
170
+ builtin
171
+ + (f"\n{custom}" if custom else "")
172
+ + "\n"
173
+ + init_line
174
+ + review_line
143
175
  + explain_line
144
176
  + "/sessions list saved sessions\n"
145
177
  "/restore [path | title | --latest | latest] restore a saved session (conversation + agent + model)\n"
146
178
  "/model [name] switch LLM model profile\n"
147
179
  "/agent [name] switch agent system prompt\n"
148
180
  "Ctrl-C cancels the current execution (app stays open); "
149
- "Ctrl-D or /exit quits.",
181
+ "Ctrl-D or /exit quits." + notes,
150
182
  markup=False,
151
183
  )
152
184
  else:
@@ -200,7 +232,8 @@ class CommandMixin:
200
232
  return None, " ".join(parts)
201
233
 
202
234
  def _run_slash_command(self, name: str, arg: str) -> None:
203
- """Run a SessionCommand (/init /review /explain) in this session.
235
+ """Run a SessionCommand (/init /review /explain, or any command file
236
+ that replaced a builtin) in this session.
204
237
 
205
238
  The command's prompt replaces the system prompt for this run
206
239
  only; the output streams into the conversation panel and stays
@@ -208,7 +241,7 @@ class CommandMixin:
208
241
  different project is given, the session's project dir is
209
242
  borrowed for the run (tool cwd) and restored afterwards.
210
243
  """
211
- cmd = find_command(name)
244
+ cmd = find_command(name, self._controller.configured_command_path)
212
245
  if cmd is None:
213
246
  self.console.print(f"[yellow]unknown command: /{safe_markup(name)}[/yellow]")
214
247
  return
@@ -428,10 +461,14 @@ class CommandMixin:
428
461
  return ["default", *sorted(self._controller.model_profiles.keys())]
429
462
 
430
463
  def _model_switch_by_name(self, name: str) -> None:
431
- """Switch to a named profile (or ``default``) and report the outcome."""
464
+ """Switch to a named profile (or ``default``).
465
+
466
+ Only failures are reported: a successful switch already shows up
467
+ in the input prompt's "model >" prefix, so an extra confirmation
468
+ line is noise.
469
+ """
432
470
  success, msg = self._controller.switch_model(name)
433
471
  if success:
434
- self.console.print(f"[green]{safe_markup(msg)}[/green]")
435
472
  self._data_event.set()
436
473
  else:
437
474
  self.console.print(f"[red]{safe_markup(msg)}[/red]")
@@ -554,23 +591,26 @@ class CommandMixin:
554
591
  self.console.print(Text(sanitize_terminal(str(msg))))
555
592
 
556
593
  def _refresh_agent_profiles(self) -> None:
557
- """Re-discover agent prompt files from the prompts/agents/ directory.
594
+ """Re-discover agent prompt files (bundled + configured directory).
558
595
 
559
596
  Agent files may be added/removed while the TUI is running;
560
597
  this re-scans so new agents show up on the next /agent call.
561
598
  """
562
- self._discovered_agents = discover_agents()
599
+ self._discovered_agents = discover_agents(self._controller.configured_agent_path)
563
600
 
564
601
  def _agent_list_names(self) -> list[str]:
565
602
  """Names shown by /agent: ``default`` followed by every
566
- discovered agent from the prompts/agents/ directory."""
603
+ discovered agent (bundled + configured directory)."""
567
604
  return [RESERVED_AGENT_NAME, *sorted(self._discovered_agents.keys())]
568
605
 
569
606
  def _agent_switch_by_name(self, name: str) -> None:
570
- """Switch to a named agent (or ``default``) and report."""
607
+ """Switch to a named agent (or ``default``).
608
+
609
+ Only failures are reported: the status bar's " @agent" segment
610
+ already reflects a successful switch.
611
+ """
571
612
  success, msg = self._controller.switch_agent(name)
572
613
  if success:
573
- self.console.print(f"[green]{safe_markup(msg)}[/green]")
574
614
  self._on_notify("agent-switched")
575
615
  else:
576
616
  self.console.print(f"[red]{safe_markup(msg)}[/red]")
@@ -583,7 +623,7 @@ class CommandMixin:
583
623
  self.console.print("\n[bold cyan]Available agent profiles:[/bold cyan]")
584
624
  if not self._discovered_agents:
585
625
  self.console.print(
586
- "[yellow] (none found — add .md files to the prompts/agents/ directory to use /agent)[/yellow]"
626
+ " [yellow](none found — add .md files to the agents directory to use /agent)[/yellow]"
587
627
  )
588
628
  active_name = getattr(self._controller.session.store, "agent", None)
589
629
  for idx, name in enumerate(all_names, 1):
@@ -686,9 +726,10 @@ class CommandMixin:
686
726
  return
687
727
 
688
728
  def report(level: str, msg: str) -> None:
689
- if level == "ok":
690
- self.console.print(f"[green]{safe_markup(msg)}[/green]")
691
- else:
729
+ # successful agent/model restores need no line of their own:
730
+ # the status bar and the input prompt's "model >" prefix
731
+ # already reflect them, only problems are worth reporting
732
+ if level != "ok":
692
733
  self.console.print(f"[yellow]warning: {safe_markup(msg)}[/yellow]")
693
734
 
694
735
  apply_saved_session(self._controller, saved, report)
@@ -701,12 +742,9 @@ class CommandMixin:
701
742
  saved_project = saved.meta.get(PROJECT_KEY)
702
743
  if saved_project:
703
744
  self._switch_input_history(saved_project)
704
- model = saved.meta.get(MODEL_KEY)
705
- agent_display = saved.meta.get(AGENT_KEY, "default")
706
745
  self.console.print(
707
746
  f"[green]restored:[/green] {safe_markup(os.path.basename(path))} "
708
- f"(model={safe_markup(model)}, agent={safe_markup(agent_display)}, "
709
- f"project={safe_markup(saved_project or '?')}, {len(saved.messages)} messages)"
747
+ f"(project={safe_markup(saved_project or '?')}, {len(saved.messages)} messages)"
710
748
  )
711
749
 
712
750
  def _switch_input_history(self, project_dir: str) -> None:
@@ -82,8 +82,9 @@ class Tui(RenderMixin, InputMixin, CommandMixin):
82
82
  # time spent once the run finishes
83
83
  self._run_start: float | None = None
84
84
  # Discovered agent profiles (name -> prompt file path) from the
85
- # prompts/agents/ directory; refreshed on each /agent call so files
86
- # added at runtime are picked up.
85
+ # bundled prompts/agents/ directory plus the configured one
86
+ # (paths.agent_path, configured names win); refreshed on each
87
+ # /agent call so files added at runtime are picked up.
87
88
  self._discovered_agents: dict[str, str] = {}
88
89
  # Tool calls the user expanded by clicking their ▶ row: their
89
90
  # panel rows carry every argument in full instead of the
@@ -100,7 +101,10 @@ class Tui(RenderMixin, InputMixin, CommandMixin):
100
101
  self._typed_during_run = ""
101
102
  self.prompt_session = _make_prompt_session(
102
103
  FileHistory(_history_path(str(self._controller.project_dir))),
103
- SlashCompleter(lambda: str(self._controller.project_dir)),
104
+ SlashCompleter(
105
+ lambda: str(self._controller.project_dir),
106
+ lambda: self._controller.configured_command_path,
107
+ ),
104
108
  )
105
109
 
106
110
  self._controller.attach_view(self)
@@ -71,7 +71,6 @@ SLASH_COMMANDS = [
71
71
  "/build",
72
72
  "/init",
73
73
  "/review",
74
- "/explain",
75
74
  "/compact",
76
75
  "/save",
77
76
  "/summary",
@@ -82,12 +81,16 @@ SLASH_COMMANDS = [
82
81
  "/agent",
83
82
  "/exit",
84
83
  ]
84
+ # NOTE: custom commands (/explain, ...) are NOT listed here — they are
85
+ # discovered from the bundled prompts/commands/ directory plus the
86
+ # configured one (paths.command_path) so the completion listing matches
87
+ # what is actually runnable, see _custom_slash_commands.
85
88
 
86
89
 
87
- def _custom_slash_commands() -> list[str]:
90
+ def _custom_slash_commands(commands_dir: str | None = None) -> list[str]:
88
91
  from ..session.commands import load_custom_commands
89
92
 
90
- return sorted(f"/{c.name}" for c in load_custom_commands())
93
+ return sorted(f"/{c.name}" for c in load_custom_commands(commands_dir))
91
94
 
92
95
 
93
96
  def _history_path(project_dir: str | None = None) -> str:
@@ -188,8 +191,9 @@ class SlashCompleter(Completer):
188
191
  """Tab-completion for the input line.
189
192
 
190
193
  - A first token starting with ``/`` completes against the known
191
- slash commands (builtins + custom commands from
192
- prompts/commands/*.md); if no command matches, it is treated as
194
+ slash commands (builtins + custom commands from the bundled
195
+ prompts/commands/ directory and the configured one,
196
+ ``paths.command_path``); if no command matches, it is treated as
193
197
  an absolute path.
194
198
  - After a slash command's space, Tab completes paths relative to
195
199
  the session's project dir (absolute and ``~`` paths work too).
@@ -201,11 +205,16 @@ class SlashCompleter(Completer):
201
205
  ``~`` alone completes to ``~/``.
202
206
  """
203
207
 
204
- def __init__(self, get_project_dir: Callable[[], str]) -> None:
208
+ def __init__(
209
+ self,
210
+ get_project_dir: Callable[[], str],
211
+ get_commands_dir: Callable[[], str | None] | None = None,
212
+ ) -> None:
205
213
  self.get_project_dir = get_project_dir
214
+ self.get_commands_dir = get_commands_dir or (lambda: None)
206
215
 
207
216
  def _slash_commands(self) -> list[str]:
208
- return sorted(set(SLASH_COMMANDS + _custom_slash_commands()))
217
+ return sorted(set(SLASH_COMMANDS + _custom_slash_commands(self.get_commands_dir())))
209
218
 
210
219
  def _complete_paths(self, arg: str) -> Iterable[Completion]:
211
220
  expanded = os.path.expanduser(arg)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-agent-harness
3
- Version: 1.5.6.9
3
+ Version: 1.5.7.2
4
4
  Summary: A lightweight, hackable mini-OpenCode written in Python.
5
5
  Author-email: Huming Chen <chenhuming@gmail.com>
6
6
  License-Expression: MIT
@@ -79,8 +79,8 @@ Edit `~/.config/python-agent-harness/config.json` and set your `base_url`, `api_
79
79
  - **Persistent sessions** — auto-saved after every response to `~/.local/share/python-agent-harness/sessions/`, with LLM-generated titles and `/restore --latest` / `/sessions`.
80
80
  - **Focused TUI** — Rich-based with pinned status bar, Todos panel, inline diff rendering, and a `prompt_toolkit` editor with history and completion. `Esc+Enter` submits, `Ctrl-D` quits, `Ctrl-C` cancels.
81
81
  - **MCP support** — optional via `[mcp]` extra. MCP tools become ordinary agent tools (`mcp__<server>__<tool>`). Supports `stdio`, `streamable-http`, and `sse` transports.
82
- - **Slash commands** — built-in `/init`, `/review`, `/explain`, etc., plus custom commands from `prompts/commands/*.md`.
83
- - **Custom agents** — switch the main agent's system prompt at runtime with `/agent`. Agent files live in `prompts/agents/*.md` and support `name:` and `exclude_tools:` frontmatter.
82
+ - **Slash commands** — built-in `/init`, `/review`, `/explain`, etc., plus custom commands from `prompts/commands/*.md` (extendable via `paths.command_path`).
83
+ - **Custom agents** — switch the main agent's system prompt at runtime with `/agent`. Agent files live in `prompts/agents/*.md` (extendable via `paths.agent_path`) and support `name:` and `exclude_tools:` frontmatter.
84
84
  - **Hooks** — shell commands on `tool.before` / `tool.after` / `agent.start` / `agent.end`: block risky tool calls, feed linter output back to the model, add per-turn context, notify on completion. See [Hooks](#hooks).
85
85
  - **Embeddable runtime boundaries** — `headless --json` for one-shot CI/scripting; `serve` for hosting apps (resident process, bidirectional protocol: multi-turn memory, mid-run Q&A, protocol-level cancel).
86
86
 
@@ -132,11 +132,11 @@ A persistent, bidirectional runtime for hosting applications. Keeps the `Control
132
132
  | `/help` | List available commands |
133
133
  | `/exit` | Quit |
134
134
 
135
- Custom commands from `prompts/commands/*.md` are also registered (TUI only).
135
+ Custom commands from `prompts/commands/*.md` and `paths.command_path` are always registered (TUI only). A command file **replaces** the command of the same name — builtin or bundled (precedence: configured > bundled > builtin), except `/exit`, which cannot be shadowed. `/help` lists the overrides.
136
136
 
137
137
  ### Custom agents
138
138
 
139
- Agent files are markdown (`.md`) in `prompts/agents/`. Each becomes a switchable profile via `/agent`. Optional YAML frontmatter:
139
+ Agent files are markdown (`.md`) in `prompts/agents/`. Files in `paths.agent_path` are merged on top (a same-named configured agent wins; the rest stay available). Each becomes a switchable profile via `/agent`. Optional YAML frontmatter:
140
140
 
141
141
  - `name:` — override the agent name (defaults to file stem)
142
142
  - `exclude_tools:` — list of tool names to hide. Matches by exact name, glob (`mcp__git__*`), or `__`-delimited prefix (`mcp__git` hides `mcp__git__list_repos` but `Write` does NOT hide `TodoWrite`).
@@ -166,7 +166,9 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
166
166
  },
167
167
  "paths": {
168
168
  "context_path": null,
169
- "skill_path": null
169
+ "skill_path": null,
170
+ "agent_path": null,
171
+ "command_path": null
170
172
  },
171
173
  "mcp": {
172
174
  "servers": {
@@ -190,8 +192,9 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
190
192
  - **`models`** — named LLM profiles for `/model` switching. Partial settings; unset keys inherit from `llm`. `default` restores the main config.
191
193
  - **`context_windows`** — per-model context-window overrides (tokens). Keys are model names or substrings; first match wins. Overrides `CONTEXT_WINDOWS` in `config.py`.
192
194
  - **`subagent_llm`** — LLM config for `Agent` tool. Unset values inherit from `llm`. Set `profile` to reuse a `models` entry. Precedence: profile > `subagent_llm` > `llm` > env vars.
193
- - **`default_agent`** — agent name to use at session start (must exist in `prompts/agents/`). `null` = built-in default.
195
+ - **`default_agent`** — agent name to use at session start (must exist in the discovered agent set: bundled `prompts/agents/` plus `paths.agent_path`). `null` = built-in default.
194
196
  - **`paths.context_path` / `paths.skill_path`** — locations for context files and skills. Default: project-local `contexts/` and `skills/`.
197
+ - **`paths.agent_path` / `paths.command_path`** — extra directories for custom agents and slash commands, **merged** on top of the bundled `prompts/agents/` and `prompts/commands/`: a same-named configured file wins, everything else stays available. Absolute paths and `~` supported. (`context_path`/`skill_path` instead *replace* the project-local default.)
195
198
  - **`mcp.servers`** — MCP server config (requires `[mcp]` extra). Each supports `transport`, `command`, `args`, `env`, `url`, `headers`, `parallel`, `timeout`, `enabled`.
196
199
  - **`headless` / `serve`** — optional budget limits: `max_rounds` (LLM rounds) and `timeout` (wall-clock seconds). `--max-rounds` / `--timeout` override per call; `<= 0` or `null` disables. Unset = unlimited.
197
200
  - **`hooks`** — shell-command hooks; see [Hooks](#hooks).
@@ -1,6 +1,5 @@
1
- python_agent_harness/__init__.py,sha256=p57NhxDoFT-2BC6r3ig2HsFGA9lLUU-tHlOam1A0h5Q,664
1
+ python_agent_harness/__init__.py,sha256=PBEmnIdeFgu69P-w-dR3n3O_RRwhsw2wI3vhNzMiwWw,664
2
2
  python_agent_harness/__main__.py,sha256=Z3IaoJ3frQAQm5Lg-1gON_hwwHUc7CkYFUg74JIVnPE,58
3
- python_agent_harness/hooks.py,sha256=MMQPamnb5IMsKBiwmoDKzgoZv9Z1sds02ChXZVMKF4o,25328
4
3
  python_agent_harness/core/__init__.py,sha256=AuGbAsl5rBoJdOgcaB5-9OGTVo3YtSVjJuQU7GEu9OU,77
5
4
  python_agent_harness/core/agent.py,sha256=VJrtbMVwFA7h2j-4UPF5Bdwu99e9hiRCLaQeuQPlqlo,41455
6
5
  python_agent_harness/core/context_manager.py,sha256=9jePb-2PUsEkPZHkiMGtjTy_fM-sQZN1KkIe3GE4IoM,4919
@@ -10,8 +9,8 @@ python_agent_harness/core/subagent.py,sha256=4gxP077iKMLg_oWo30ll6FCptfcd9e9gtne
10
9
  python_agent_harness/core/token_estimator.py,sha256=AnEnt6XKsm0E2KQHe4ZOYOMz08VGQII0AizTwDxgx2Y,6725
11
10
  python_agent_harness/core/tool_runner.py,sha256=ZTyQF013EutrM28Kb5AmiDu972ktOj4aR_DH8QLuc9s,15885
12
11
  python_agent_harness/entry/__init__.py,sha256=XIJavZAikYTwneF5h6NetS1TcjgzzIKyZze4UK50sFY,76
13
- python_agent_harness/entry/cli.py,sha256=h6_Nx8Eznla8SbLggSxOGGfQ_Hur_uGeMV4klU_e8PM,21419
14
- python_agent_harness/entry/controller.py,sha256=O8mBw1gC0-t3VyKnWLATRn0ozBYWDrjs_ZLwmxBSS3Q,20369
12
+ python_agent_harness/entry/cli.py,sha256=w0kKmEUKTppkfm9JMe9pY6Dw4TnAUqJ7vZF243QHkAE,21720
13
+ python_agent_harness/entry/controller.py,sha256=9aaUDqeqX8e-29qVY7YWtHKJRaOOUrBljJ4IyUmq0_E,20615
15
14
  python_agent_harness/entry/headless.py,sha256=xW-HGg3TPqATQPDVuzl1bGfEj-rLzaINCPACe5LINko,26663
16
15
  python_agent_harness/entry/restore.py,sha256=kZhBsSs7ZMslylHQKj6KA_Co1TI7T7wAzD5fLRBtNWo,5952
17
16
  python_agent_harness/entry/server.py,sha256=tkVSntiXIxhPnOEcpsqPiM_g7Bo9mdhpfhuEtOdgh2c,44851
@@ -22,16 +21,16 @@ python_agent_harness/io/diffrender.py,sha256=HEOaAjKXZ6euPv-wlEP75304ceLME4ttRDp
22
21
  python_agent_harness/io/persistence.py,sha256=U2mEPJPBGmlcN0PstxKlbc4DJ5P1OAnYG2GQbRyo7AI,15941
23
22
  python_agent_harness/io/text_filter.py,sha256=B4RkF-cFu_lblQejne9_lC_ZjaOFcbRhrcxAmInGaLI,11507
24
23
  python_agent_harness/llm/__init__.py,sha256=osSA7cec8RtjDURa6kbTZwjv0t31opMmmPtjyaxKFjs,22
25
- python_agent_harness/llm/client.py,sha256=oI3hWfGT5cIJ-fNzGPuVGc37oXnZFq2PMPWYPgEh3pA,47931
24
+ python_agent_harness/llm/client.py,sha256=QS9MsB5LG_uXfkV3vlIOtRIyUSntYA6bAt9rh1r_T-k,48390
26
25
  python_agent_harness/mcp/__init__.py,sha256=dlgZRr_pljESu-aJfo3aq_fLDkZN7quwrPUR112Kohw,535
27
26
  python_agent_harness/mcp/client.py,sha256=BnBPuX5Pn9-3KBpWXPeC1bPVYOJl8eNpk0XvupD9eOw,6212
28
- python_agent_harness/mcp/config.py,sha256=XpeB0AzWTCI6BoDqScsKzjBt5BPHgaCc58WEJfsvPRM,4894
27
+ python_agent_harness/mcp/config.py,sha256=XMxBndLw_5EwGNbjyfIhxud6IYM2VHTsUVwU2cqkoy0,5506
29
28
  python_agent_harness/mcp/manager.py,sha256=5yAT7yf58SJEMLGBVihOtO11hjmIMUYI7aRNJtcVJMs,11814
30
29
  python_agent_harness/prompts/__init__.py,sha256=X8fYIv5aeWYCRYon5ksuX17L-ppZrtUvRNk1s7D3hw4,995
31
30
  python_agent_harness/prompts/agent.md,sha256=QeBtoZHT4oSjZ0wV3Kq45kwEAxekL7INQr35OTgbhF8,6361
32
31
  python_agent_harness/prompts/build-switch.md,sha256=Xj22FqaFo9-q-V-4aubirPvfUgvaYPeyf3J9Koi6iiU,233
33
32
  python_agent_harness/prompts/compact.md,sha256=hz2yNyp-RteD5fUKqDfyPbM3SOhjEoinRLYSx1htXNo,978
34
- python_agent_harness/prompts/core.py,sha256=dvJSY2S8TndYH7_iEVSjY7Tz4irarJ91WFKv1pktuKU,27605
33
+ python_agent_harness/prompts/core.py,sha256=S3aBYfIBTenB8-dbnZOTo0zhESGI_wBpHY3wS36xUnk,28856
35
34
  python_agent_harness/prompts/initialize.md,sha256=kgnEjtFqnKXLg38Jgxgnzhhn7B3bM8ahrRl3kypnkyg,3492
36
35
  python_agent_harness/prompts/plan-mode.md,sha256=ExEfFuukjzMQiUEYOccLleOO1S5tJDo-Hdi8IC_blow,4551
37
36
  python_agent_harness/prompts/plan.md,sha256=NJWArCzBzXOvJssCrbFfoGdzf0s6k3Qtlz_dO8hjf9Y,1479
@@ -43,9 +42,10 @@ python_agent_harness/prompts/title.md,sha256=56aEjroyjyjH6HCHTPBZHk7br5DXYCrY_f6
43
42
  python_agent_harness/prompts/agents/reviewer.md,sha256=rcj2jiY6S8PQhWfvXXt9h3T11PuofVcAvDKTBmDoYAs,414
44
43
  python_agent_harness/prompts/commands/explain.md,sha256=RMmP9L3TfPpW0dthlGobWbgqBIc7H2LJIMIJT2JDN3Y,539
45
44
  python_agent_harness/session/__init__.py,sha256=SdMrMuRupRhIyUjJLb0EEmB5KtgDmKORV_qDZUpEYEw,937
46
- python_agent_harness/session/commands.py,sha256=2nCW0Q4JcClP2SheDuyU7LInTS9LORCDw7cyxQaYE_w,5517
47
- python_agent_harness/session/config.py,sha256=5tJ0mcYin5l1ws5c6XeKUezTscmi7kGZ4JBg2J4gklc,31213
48
- python_agent_harness/session/session.py,sha256=vu1xTE4xeflL1myb-YrEiaoGJq8vtDXyJ_irx4H_F40,50743
45
+ python_agent_harness/session/commands.py,sha256=kqp0JVOg2Ls9QEtx2ViA6p5xSnBcDp9y_aY2mNSaysM,8895
46
+ python_agent_harness/session/config.py,sha256=5rg3heS-1vEIcPESLiXP-hNgKlj_XoT6haGXKrd6Jn0,31718
47
+ python_agent_harness/session/hooks.py,sha256=JNIDOqI26Rb9NTPay8EHHCFx0mbSKilILEcfQFfRTS4,25329
48
+ python_agent_harness/session/session.py,sha256=L1GxrmShGwNRmNjgBX83p3Gdo3M8GKwStEpdZ2OsB9g,51273
49
49
  python_agent_harness/tools/__init__.py,sha256=3fPlb6x_TW-n87Tz2GFGfBKtpvq2nvaI10gjj8We4RM,1639
50
50
  python_agent_harness/tools/agent_tool.py,sha256=dw_q5v1q3hT0l-qLWz3po36y7HM_FtqOudXLFp0V4us,5319
51
51
  python_agent_harness/tools/base.py,sha256=-fLBnDoX3mk0J6DzZfy0nDXrGXA6OtXhUmeQUSu7ALM,9618
@@ -53,27 +53,27 @@ python_agent_harness/tools/bash.py,sha256=GLDIYV6VpVpfMZWe484gUZfDeTWmREMF-xZvnv
53
53
  python_agent_harness/tools/diffapply.py,sha256=Mz335K9m632gAptJMqgTGa1WbhFJcWG8avHR3xs0BwM,12245
54
54
  python_agent_harness/tools/edit.py,sha256=3acQCDUzF6pw2otztIFTSQmMwn6A46XwOkcKn_nJCns,15892
55
55
  python_agent_harness/tools/edit_mac.py,sha256=XXTS5_4UtZ5YQtiYe1bk1Q4cdW5XqCtRCMQkcKr3Mv4,2176
56
- python_agent_harness/tools/filesystem.py,sha256=LR7Fw5-diQtRoiSba_Qy1X0A2scC1b4RMh59c8RhZhw,11362
56
+ python_agent_harness/tools/filesystem.py,sha256=btutgEVM6ssfmxBNbgUrflBN6qwUARAlw6ZGI7UpEsw,12069
57
57
  python_agent_harness/tools/glob.py,sha256=LFTLdQs_MUiSsk0ZN5Oc2JA0aY2qPCna3oCUhWxR6Cw,7107
58
58
  python_agent_harness/tools/glob_mac.py,sha256=xq-XxUujo24hIHMY89CRnqK03DaFaEZfNmEBPTl-394,4091
59
- python_agent_harness/tools/grep.py,sha256=_19FEw9j03DeiY2aZeWpz_fr7Yc4MtZXPrH1UXJjEMY,7124
59
+ python_agent_harness/tools/grep.py,sha256=4VCUzu-_h_wywdeMbMxzpWXBsv4jy7I7u8B0Coh-rE8,7124
60
60
  python_agent_harness/tools/grep_mac.py,sha256=UfMtVnhjgj_qlO3k79LjAF8_u7OJomsF9I0dM5e8s4A,5918
61
61
  python_agent_harness/tools/mcp.py,sha256=v_XMOfxGpaJ3xw3i4j3HOz03qhMluGfLotLZSQPD_Ac,7489
62
62
  python_agent_harness/tools/planexit.py,sha256=ogmoTBBQ0klNe0ktLiVn6dEU4j3J8CdqS7UwvKMZLxY,1935
63
63
  python_agent_harness/tools/question.py,sha256=G1d40hazlYnf1oBJCGpf4pri2gKPa1lGeO5QY61tpxk,3358
64
- python_agent_harness/tools/read.py,sha256=ISOH_8xQnsoBT0NGme0BlHwKlWsJsJxg2Ro9EaM3uiA,5081
64
+ python_agent_harness/tools/read.py,sha256=4c_Dj424ipTrtXq8Dqd0B2Juy3Za6QtSFsromSjw0Tg,5153
65
65
  python_agent_harness/tools/skill.py,sha256=Fk5i8UZ_Qamoc4v1owxjmDi2FCnKIezu_gZRuGfdTSg,1118
66
66
  python_agent_harness/tools/todo.py,sha256=1BO8ZAmfHlswujjy_gFL0eID8DZphyiCjPJJ7AqhaYY,4294
67
- python_agent_harness/tools/write.py,sha256=xQscOZdHVVMDKCHUGwqctU8Fzmn_YkGLzL3KZuCV0gY,3956
67
+ python_agent_harness/tools/write.py,sha256=PnLp86Cl0aMSPcL_3gNeoxExgj0yAX8-71fun_UhDwY,4008
68
68
  python_agent_harness/tui/__init__.py,sha256=Fgs8gTIzVgVUksKcjOopFDvwR9gQCaEeJ-aUTHpQbhE,1626
69
- python_agent_harness/tui/commands.py,sha256=StsVsUoT4zBWowmK2wRUnAVHz1AFmMnNFMIs4Y1IYro,31661
70
- python_agent_harness/tui/core.py,sha256=Jc7HLb4ZG9nhjaUzGNaiYoDLlHn9ye6ifQ4lXJwTN1g,25130
71
- python_agent_harness/tui/input.py,sha256=IQJTO9VPk73AKQXj4-3WihGuclthOjlQLlKzXrLDlz0,20646
69
+ python_agent_harness/tui/commands.py,sha256=Eat1nljKoD2z3MfPORHc-drWsnUdyfRMr_nUcP_T1_Y,33462
70
+ python_agent_harness/tui/core.py,sha256=BjqOK3qIlHZVNzn5dRd9Vg30UgI76UgjM3cV398DTd4,25310
71
+ python_agent_harness/tui/input.py,sha256=wRpPzSOKST2WAYeRQ3I72-64KzhztQ_FoFhTNpTtg7A,21192
72
72
  python_agent_harness/tui/mouse.py,sha256=VEKOqM0mrSn_sZNDHZtSn_xCYiEZOKQlL_3l-LXRj30,15262
73
73
  python_agent_harness/tui/render.py,sha256=0i22IOuTE0TPg8428t35uc6fR6wSjp6ZcjWBJ7v6xzk,55239
74
- python_agent_harness-1.5.6.9.dist-info/licenses/LICENSE,sha256=TiuVaM7FrBunbEua5l_01IT-mwccvS51CLrDLuKW96g,1066
75
- python_agent_harness-1.5.6.9.dist-info/METADATA,sha256=cMGh_5JboJ5kOFWolp4YBSsykKQiImllVxCfh7hPLD0,14876
76
- python_agent_harness-1.5.6.9.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
77
- python_agent_harness-1.5.6.9.dist-info/entry_points.txt,sha256=W0fmwiwUzs9ORhJRF3oG0i5ku3qg5k2wrDACUqWR0wk,77
78
- python_agent_harness-1.5.6.9.dist-info/top_level.txt,sha256=MQXIVidl0IBeeKnLHhy1JfzXNQMBKAehpdkqHVvIfwM,21
79
- python_agent_harness-1.5.6.9.dist-info/RECORD,,
74
+ python_agent_harness-1.5.7.2.dist-info/licenses/LICENSE,sha256=TiuVaM7FrBunbEua5l_01IT-mwccvS51CLrDLuKW96g,1066
75
+ python_agent_harness-1.5.7.2.dist-info/METADATA,sha256=9dLTRctgawS8XBUTZhaTH-Lr07wO5k1KCyd-_TSEIUU,15752
76
+ python_agent_harness-1.5.7.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
77
+ python_agent_harness-1.5.7.2.dist-info/entry_points.txt,sha256=W0fmwiwUzs9ORhJRF3oG0i5ku3qg5k2wrDACUqWR0wk,77
78
+ python_agent_harness-1.5.7.2.dist-info/top_level.txt,sha256=MQXIVidl0IBeeKnLHhy1JfzXNQMBKAehpdkqHVvIfwM,21
79
+ python_agent_harness-1.5.7.2.dist-info/RECORD,,