python-agent-harness 1.5.7.5__tar.gz → 1.5.7.6__tar.gz

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.
Files changed (88) hide show
  1. {python_agent_harness-1.5.7.5/python_agent_harness.egg-info → python_agent_harness-1.5.7.6}/PKG-INFO +15 -13
  2. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/README.md +14 -12
  3. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/pyproject.toml +7 -2
  4. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/__init__.py +1 -1
  5. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/core/subagent.py +2 -2
  6. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/core/token_estimator.py +1 -13
  7. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/cli.py +34 -27
  8. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/controller.py +13 -9
  9. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/restore.py +7 -2
  10. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/server.py +0 -21
  11. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/io/persistence.py +55 -4
  12. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/__init__.py +1 -0
  13. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/core.py +103 -69
  14. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/session/commands.py +38 -26
  15. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/session/config.py +103 -111
  16. python_agent_harness-1.5.7.6/python_agent_harness/session/config_template.json +102 -0
  17. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/session/session.py +107 -63
  18. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/commands.py +70 -12
  19. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/core.py +18 -3
  20. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/input.py +9 -7
  21. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/mouse.py +0 -20
  22. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6/python_agent_harness.egg-info}/PKG-INFO +15 -13
  23. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/SOURCES.txt +1 -0
  24. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/LICENSE +0 -0
  25. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/__main__.py +0 -0
  26. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/core/__init__.py +0 -0
  27. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/core/agent.py +0 -0
  28. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/core/context_manager.py +0 -0
  29. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/core/models.py +0 -0
  30. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/core/planmode.py +0 -0
  31. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/core/tool_runner.py +0 -0
  32. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/__init__.py +0 -0
  33. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/headless.py +0 -0
  34. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/entry/view.py +0 -0
  35. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/io/__init__.py +0 -0
  36. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/io/attachments.py +0 -0
  37. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/io/diffrender.py +0 -0
  38. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/io/text_filter.py +0 -0
  39. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/llm/__init__.py +0 -0
  40. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/llm/client.py +0 -0
  41. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/mcp/__init__.py +0 -0
  42. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/mcp/client.py +0 -0
  43. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/mcp/config.py +0 -0
  44. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/mcp/manager.py +0 -0
  45. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/agent.md +0 -0
  46. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/agents/reviewer.md +0 -0
  47. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/build-switch.md +0 -0
  48. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/commands/explain.md +0 -0
  49. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/compact.md +0 -0
  50. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/initialize.md +0 -0
  51. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/plan-mode.md +0 -0
  52. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/plan.md +0 -0
  53. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/review.md +0 -0
  54. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/subagent.md +0 -0
  55. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/summary.md +0 -0
  56. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/task-completion-rules.md +0 -0
  57. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/title.md +0 -0
  58. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/prompts/tool-usage-policy.md +0 -0
  59. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/session/__init__.py +0 -0
  60. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/session/hooks.py +0 -0
  61. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/__init__.py +0 -0
  62. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/agent_tool.py +0 -0
  63. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/base.py +0 -0
  64. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/bash.py +0 -0
  65. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/diffapply.py +0 -0
  66. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/edit.py +0 -0
  67. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/edit_mac.py +0 -0
  68. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/filesystem.py +0 -0
  69. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/glob.py +0 -0
  70. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/glob_mac.py +0 -0
  71. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/grep.py +0 -0
  72. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/grep_mac.py +0 -0
  73. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/mcp.py +0 -0
  74. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/planexit.py +0 -0
  75. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/question.py +0 -0
  76. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/read.py +0 -0
  77. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/skill.py +0 -0
  78. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/todo.py +0 -0
  79. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tools/write.py +0 -0
  80. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/__init__.py +0 -0
  81. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness/tui/render.py +0 -0
  82. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/dependency_links.txt +0 -0
  83. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/entry_points.txt +0 -0
  84. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/requires.txt +0 -0
  85. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/python_agent_harness.egg-info/top_level.txt +0 -0
  86. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/setup.cfg +0 -0
  87. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/tests/test_invariants.py +0 -0
  88. {python_agent_harness-1.5.7.5 → python_agent_harness-1.5.7.6}/tests/test_scenarios.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-agent-harness
3
- Version: 1.5.7.5
3
+ Version: 1.5.7.6
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` (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.
82
+ - **Slash commands** — built-in `/init`, `/review`, `/explain`, etc., plus custom commands from `prompts/commands/*.md` (extendable via `paths.command_paths`).
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_paths`) 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
 
@@ -126,17 +126,18 @@ A persistent, bidirectional runtime for hosting applications. Keeps the `Control
126
126
  | `/save` | Save the current session |
127
127
  | `/sessions` | List saved sessions |
128
128
  | `/restore [path\|title\|--latest\|latest]` | Restore a session (substring search) |
129
- | `/clear` | Start a fresh conversation |
129
+ | `/clear` | Wipe the conversation but keep the session file (the next save overwrites it) |
130
+ | `/new` | Start a new session in a new file; the current one is saved first (with auto-save on) and stays restorable |
130
131
  | `/model [name]` | Switch LLM profiles; `default` restores original |
131
132
  | `/agent [name]` | Switch agent prompt; `default` restores built-in |
132
133
  | `/help` | List available commands |
133
134
  | `/exit` | Quit |
134
135
 
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
+ Custom commands from `prompts/commands/*.md` and `paths.command_paths` 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
137
 
137
138
  ### Custom agents
138
139
 
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`, except `default`, which cannot be shadowed. Optional YAML frontmatter:
140
+ Agent files are markdown (`.md`) in `prompts/agents/`. Files in `paths.agent_paths` are merged on top (a same-named configured agent wins; the rest stay available). Each becomes a switchable profile via `/agent`, except `default`, which cannot be shadowed. Optional YAML frontmatter:
140
141
 
141
142
  - `name:` — override the agent name (defaults to file stem)
142
143
  - `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`).
@@ -168,10 +169,10 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
168
169
  "max_nudges": 1
169
170
  },
170
171
  "paths": {
171
- "context_path": null,
172
- "skill_path": null,
173
- "agent_path": null,
174
- "command_path": null
172
+ "context_paths": null,
173
+ "skill_paths": null,
174
+ "agent_paths": null,
175
+ "command_paths": null
175
176
  },
176
177
  "mcp": {
177
178
  "servers": {
@@ -196,9 +197,10 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
196
197
  - **`context_windows`** — per-model context-window overrides (tokens). Keys are model names or substrings; first match wins. Overrides `CONTEXT_WINDOWS` in `config.py`.
197
198
  - **`supervision.max_nudges`** — completion-supervision budget: how many times the harness nudges the model back to work when it stops with a terminal answer. The budget is **per tool round** (it resets on every tool round), so the effective cap is `max_nudges × tool rounds`. Default `1`, which suits a model that rarely stops early; raise it for a weaker model that keeps stopping before the work is done, or set `0` to disable supervision. Each nudge costs one extra LLM round (a full history re-send), so a high value is expensive.
198
199
  - **`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.
199
- - **`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.
200
- - **`paths.context_path` / `paths.skill_path`** — locations for context files and skills. Default: project-local `contexts/` and `skills/`.
201
- - **`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.)
200
+ - **`default_agent`** — agent name to use at session start (must exist in the discovered agent set: bundled `prompts/agents/` plus `paths.agent_paths`). `null` = built-in default.
201
+ - **`paths.context_paths` / `paths.skill_paths`** — locations for context files and skills. Default: project-local `contexts/` and `skills/`.
202
+ - **`paths.agent_paths` / `paths.command_paths`** — 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. (`context_paths`/`skill_paths` instead *replace* the project-local default.)
203
+ - **Every `paths.*` value is a single path or a list of paths** — absolute paths and `~` supported. With a list, all directories are used and an earlier one wins over a later one for the same name.
202
204
  - **`mcp.servers`** — MCP server config (requires `[mcp]` extra). Each supports `transport`, `command`, `args`, `env`, `url`, `headers`, `parallel`, `timeout`, `enabled`.
203
205
  - **`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.
204
206
  - **`hooks`** — shell-command hooks; see [Hooks](#hooks).
@@ -45,8 +45,8 @@ Edit `~/.config/python-agent-harness/config.json` and set your `base_url`, `api_
45
45
  - **Persistent sessions** — auto-saved after every response to `~/.local/share/python-agent-harness/sessions/`, with LLM-generated titles and `/restore --latest` / `/sessions`.
46
46
  - **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.
47
47
  - **MCP support** — optional via `[mcp]` extra. MCP tools become ordinary agent tools (`mcp__<server>__<tool>`). Supports `stdio`, `streamable-http`, and `sse` transports.
48
- - **Slash commands** — built-in `/init`, `/review`, `/explain`, etc., plus custom commands from `prompts/commands/*.md` (extendable via `paths.command_path`).
49
- - **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.
48
+ - **Slash commands** — built-in `/init`, `/review`, `/explain`, etc., plus custom commands from `prompts/commands/*.md` (extendable via `paths.command_paths`).
49
+ - **Custom agents** — switch the main agent's system prompt at runtime with `/agent`. Agent files live in `prompts/agents/*.md` (extendable via `paths.agent_paths`) and support `name:` and `exclude_tools:` frontmatter.
50
50
  - **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).
51
51
  - **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).
52
52
 
@@ -92,17 +92,18 @@ A persistent, bidirectional runtime for hosting applications. Keeps the `Control
92
92
  | `/save` | Save the current session |
93
93
  | `/sessions` | List saved sessions |
94
94
  | `/restore [path\|title\|--latest\|latest]` | Restore a session (substring search) |
95
- | `/clear` | Start a fresh conversation |
95
+ | `/clear` | Wipe the conversation but keep the session file (the next save overwrites it) |
96
+ | `/new` | Start a new session in a new file; the current one is saved first (with auto-save on) and stays restorable |
96
97
  | `/model [name]` | Switch LLM profiles; `default` restores original |
97
98
  | `/agent [name]` | Switch agent prompt; `default` restores built-in |
98
99
  | `/help` | List available commands |
99
100
  | `/exit` | Quit |
100
101
 
101
- 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.
102
+ Custom commands from `prompts/commands/*.md` and `paths.command_paths` 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.
102
103
 
103
104
  ### Custom agents
104
105
 
105
- 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`, except `default`, which cannot be shadowed. Optional YAML frontmatter:
106
+ Agent files are markdown (`.md`) in `prompts/agents/`. Files in `paths.agent_paths` are merged on top (a same-named configured agent wins; the rest stay available). Each becomes a switchable profile via `/agent`, except `default`, which cannot be shadowed. Optional YAML frontmatter:
106
107
 
107
108
  - `name:` — override the agent name (defaults to file stem)
108
109
  - `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`).
@@ -134,10 +135,10 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
134
135
  "max_nudges": 1
135
136
  },
136
137
  "paths": {
137
- "context_path": null,
138
- "skill_path": null,
139
- "agent_path": null,
140
- "command_path": null
138
+ "context_paths": null,
139
+ "skill_paths": null,
140
+ "agent_paths": null,
141
+ "command_paths": null
141
142
  },
142
143
  "mcp": {
143
144
  "servers": {
@@ -162,9 +163,10 @@ All LLM settings live in `~/.config/python-agent-harness/config.json`. Environme
162
163
  - **`context_windows`** — per-model context-window overrides (tokens). Keys are model names or substrings; first match wins. Overrides `CONTEXT_WINDOWS` in `config.py`.
163
164
  - **`supervision.max_nudges`** — completion-supervision budget: how many times the harness nudges the model back to work when it stops with a terminal answer. The budget is **per tool round** (it resets on every tool round), so the effective cap is `max_nudges × tool rounds`. Default `1`, which suits a model that rarely stops early; raise it for a weaker model that keeps stopping before the work is done, or set `0` to disable supervision. Each nudge costs one extra LLM round (a full history re-send), so a high value is expensive.
164
165
  - **`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.
165
- - **`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.
166
- - **`paths.context_path` / `paths.skill_path`** — locations for context files and skills. Default: project-local `contexts/` and `skills/`.
167
- - **`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.)
166
+ - **`default_agent`** — agent name to use at session start (must exist in the discovered agent set: bundled `prompts/agents/` plus `paths.agent_paths`). `null` = built-in default.
167
+ - **`paths.context_paths` / `paths.skill_paths`** — locations for context files and skills. Default: project-local `contexts/` and `skills/`.
168
+ - **`paths.agent_paths` / `paths.command_paths`** — 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. (`context_paths`/`skill_paths` instead *replace* the project-local default.)
169
+ - **Every `paths.*` value is a single path or a list of paths** — absolute paths and `~` supported. With a list, all directories are used and an earlier one wins over a later one for the same name.
168
170
  - **`mcp.servers`** — MCP server config (requires `[mcp]` extra). Each supports `transport`, `command`, `args`, `env`, `url`, `headers`, `parallel`, `timeout`, `enabled`.
169
171
  - **`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.
170
172
  - **`hooks`** — shell-command hooks; see [Hooks](#hooks).
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python-agent-harness"
7
- version = "1.5.7.5"
7
+ version = "1.5.7.6"
8
8
  description = "A lightweight, hackable mini-OpenCode written in Python."
9
9
  authors = [
10
10
  {name = "Huming Chen", email = "chenhuming@gmail.com"}
@@ -63,7 +63,12 @@ python-agent-harness = "python_agent_harness.entry.cli:main"
63
63
  include = ["python_agent_harness*"]
64
64
 
65
65
  [tool.setuptools.package-data]
66
- python_agent_harness = ["prompts/*.md", "prompts/commands/*.md", "prompts/agents/*.md"]
66
+ python_agent_harness = [
67
+ "prompts/*.md",
68
+ "prompts/commands/*.md",
69
+ "prompts/agents/*.md",
70
+ "session/config_template.json",
71
+ ]
67
72
 
68
73
  [tool.ruff]
69
74
  line-length = 100
@@ -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.7.5"
10
+ __version__ = "1.5.7.6"
11
11
 
12
12
  __all__ = [
13
13
  "Client",
@@ -29,10 +29,10 @@ def _subagent_system_prompt(session: object) -> str | None:
29
29
  return own
30
30
  registry = getattr(session, "registry", None)
31
31
  tool_instructions = registry.tool_instructions() if registry else None
32
- skill_dir = getattr(session, "_skill_dir", None)
32
+ skill_dirs = getattr(session, "_skill_dirs", None)
33
33
  return load_agent_prompt(
34
34
  config.DEFAULT_SUBAGENT_PROMPT_FILE,
35
- skill_dir=skill_dir,
35
+ skill_dirs=skill_dirs,
36
36
  tool_instructions=tool_instructions,
37
37
  excluded_tools=config.SUBAGENT_EXCLUDED_TOOLS,
38
38
  )
@@ -14,19 +14,7 @@ import re
14
14
  from ..session import config
15
15
  from .models import extract_reasoning
16
16
 
17
-
18
- def is_cjk_char(c: str) -> bool:
19
- """Return True if C is a CJK or full-width character."""
20
- cp = ord(c)
21
- return (
22
- 0x3000 <= cp <= 0x9FFF # CJK + kana + punctuation
23
- or 0xF900 <= cp <= 0xFAFF # CJK compat ideographs
24
- or 0xFF00 <= cp <= 0xFFEF # full-width forms
25
- or 0x20000 <= cp <= 0x2FA1F # CJK extensions B-F
26
- )
27
-
28
-
29
- # The same ranges as `is_cjk_char`, as a single compiled character class.
17
+ # The CJK/full-width ranges, as a single compiled character class.
30
18
  # Scanning for CJK runs in C (the regex engine) instead of a per-character
31
19
  # Python loop, so large payloads count CJK chars much faster.
32
20
  _CJK_RE = re.compile(r"[\u3000-\u9fff\uf900-\ufaff\uff00-\uffef\U00020000-\U0002fa1f]")
@@ -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, or paths.command_path) — like init, review,
11
+ Custom commands (prompts/commands/*.md, or paths.command_paths) — 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
 
@@ -89,27 +89,27 @@ def make_session(
89
89
  # path, and a separate sub-agent log would fragment debugging
90
90
  subagent_client.log_path = client.log_path
91
91
  from ..prompts import assemble_agent_prompt, load_agent_prompt
92
- from ..session.session import find_skill_dir
92
+ from ..session.session import find_skill_dirs
93
93
 
94
94
  abs_project = os.path.abspath(os.path.expanduser(project_dir))
95
- skill_dir = find_skill_dir(abs_project, paths.get("skill_path"))
95
+ skill_dirs = find_skill_dirs(abs_project, paths.get("skill_paths"))
96
96
  registry = default_registry()
97
97
  tool_instructions = registry.tool_instructions()
98
98
  system_prompt = assemble_agent_prompt(
99
99
  abs_project,
100
100
  load_agent_prompt(
101
101
  config.DEFAULT_AGENT_PROMPT_FILE,
102
- skill_dir=skill_dir,
102
+ skill_dirs=skill_dirs,
103
103
  tool_instructions=tool_instructions,
104
104
  ),
105
- context_path=paths.get("context_path"),
105
+ context_paths=paths.get("context_paths"),
106
106
  )
107
107
  # sub-agents get ONLY their own system prompt — no parent project
108
108
  # context and no task-completion rules injected. Tool instructions
109
109
  # are filtered to exclude tools sub-agents cannot use.
110
110
  subagent_system_prompt = load_agent_prompt(
111
111
  config.DEFAULT_SUBAGENT_PROMPT_FILE,
112
- skill_dir=skill_dir,
112
+ skill_dirs=skill_dirs,
113
113
  tool_instructions=tool_instructions,
114
114
  excluded_tools=config.SUBAGENT_EXCLUDED_TOOLS,
115
115
  )
@@ -145,10 +145,10 @@ def make_session(
145
145
  ),
146
146
  subagent_supports_image_input=subagent_overrides.get("supports_image_input"),
147
147
  registry=registry,
148
- context_path=paths.get("context_path"),
149
- skill_path=paths.get("skill_path"),
150
- agent_path=paths.get("agent_path"),
151
- command_path=paths.get("command_path"),
148
+ context_paths=paths.get("context_paths"),
149
+ skill_paths=paths.get("skill_paths"),
150
+ agent_paths=paths.get("agent_paths"),
151
+ command_paths=paths.get("command_paths"),
152
152
  mcp=mcp_config,
153
153
  model_profiles=model_profiles,
154
154
  default_agent=default_agent,
@@ -156,6 +156,7 @@ def make_session(
156
156
  config_path=config_path,
157
157
  )
158
158
  session.install_hooks(hook_specs)
159
+ session.startup_warnings.extend(config.legacy_paths_warnings(config_path))
159
160
  if default_agent and default_agent != RESERVED_AGENT_NAME:
160
161
  ok, msg = session.switch_agent(default_agent)
161
162
  if not ok:
@@ -278,13 +279,13 @@ def cmd_serve(args: argparse.Namespace) -> int:
278
279
 
279
280
 
280
281
  def cmd_config(args: argparse.Namespace) -> int:
281
- path = config._config_path(args.path)
282
+ path = config._config_path(args.path or getattr(args, "config", None))
282
283
  if args.init:
283
284
  # 0o700 dir / 0o600 file: the config holds the API key, so it must
284
285
  # not be group/world-readable (mode applies to a NEW leaf dir only;
285
286
  # an existing directory keeps its permissions).
286
287
  path.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
287
- template = config.CONFIG_TEMPLATE.format(path=str(path).replace("\\", "\\\\"))
288
+ template = config.render_config_template(path)
288
289
  try:
289
290
  # O_EXCL: create-only, atomically -- no exists()/write race, and
290
291
  # a pre-planted symlink at PATH is refused instead of followed.
@@ -296,10 +297,10 @@ def cmd_config(args: argparse.Namespace) -> int:
296
297
  f.write(template)
297
298
  print(f"wrote config template: {path}")
298
299
  return 0
299
- settings = config.load_llm_config(args.path)
300
- subagent_settings = config.load_subagent_llm_config(args.path, main=settings)
301
- paths = config.load_paths_config(args.path)
302
- mcp_config = config.load_mcp_config(args.path)
300
+ settings = config.load_llm_config(path)
301
+ subagent_settings = config.load_subagent_llm_config(path, main=settings)
302
+ paths = config.load_paths_config(path)
303
+ mcp_config = config.load_mcp_config(path)
303
304
  print(f"config file: {path}")
304
305
  if not path.exists():
305
306
  print("(file does not exist yet — run `python-agent-harness config --init` to create it)")
@@ -311,10 +312,16 @@ def cmd_config(args: argparse.Namespace) -> int:
311
312
  print(f"reasoning_effort: {settings['reasoning_effort']}")
312
313
  print(f"stream: {settings['stream']}")
313
314
  print(f"timeout: {settings['timeout']}")
314
- print(f"context_path: {paths['context_path'] or '(default: <project>/contexts)'}")
315
- print(f"skill_path: {paths['skill_path'] or '(default: <project>/skills)'}")
316
- print(f"agent_path: {paths['agent_path'] or '(unset: bundled prompts/agents only)'}")
317
- print(f"command_path: {paths['command_path'] or '(unset: bundled prompts/commands only)'}")
315
+ for key, unset in (
316
+ ("context_paths", "(default: <project>/contexts)"),
317
+ ("skill_paths", "(default: <project>/skills)"),
318
+ ("agent_paths", "(unset: bundled prompts/agents only)"),
319
+ ("command_paths", "(unset: bundled prompts/commands only)"),
320
+ ):
321
+ dirs = paths[key]
322
+ print(f"{key}: {', '.join(dirs) if dirs else unset}")
323
+ for warning in config.legacy_paths_warnings(path):
324
+ print(f"warning: {warning}")
318
325
  if mcp_config.servers:
319
326
  for name, server in mcp_config.servers.items():
320
327
  status = "enabled" if server.enabled else "disabled"
@@ -330,7 +337,7 @@ def cmd_config(args: argparse.Namespace) -> int:
330
337
  else:
331
338
  print('mcp: (none configured — add an "mcp" section to the config file)')
332
339
  try:
333
- hooks = config.load_hooks(args.path)
340
+ hooks = config.load_hooks(path)
334
341
  except ValueError as e:
335
342
  print(f"hooks: INVALID — {e}")
336
343
  else:
@@ -353,7 +360,7 @@ def cmd_config(args: argparse.Namespace) -> int:
353
360
  f"reasoning_effort={subagent_settings['reasoning_effort']} "
354
361
  f"stream={subagent_settings['stream']} timeout={subagent_settings['timeout']}"
355
362
  )
356
- model_profiles = config.load_models_config(args.path)
363
+ model_profiles = config.load_models_config(path)
357
364
  if model_profiles:
358
365
  print("models:")
359
366
  for name, profile in sorted(model_profiles.items()):
@@ -362,17 +369,17 @@ def cmd_config(args: argparse.Namespace) -> int:
362
369
  print(f" {name}: model={model_name}, base_url={base_url}")
363
370
  else:
364
371
  print("models: (none configured — add a 'models' section to use /model)")
365
- context_windows = config.load_context_windows_config(args.path)
372
+ context_windows = config.load_context_windows_config(path)
366
373
  if context_windows:
367
374
  print("context_windows:")
368
375
  for pattern, size in context_windows:
369
376
  print(f" {pattern}: {size}")
370
377
  else:
371
378
  print("context_windows: (none configured — built-in table in config.py applies)")
372
- default_agent = config.load_default_agent(args.path)
379
+ default_agent = config.load_default_agent(path)
373
380
  print(f"default_agent: {default_agent or '(default: agent.md)'}")
374
- print(f"supervision.max_nudges: {config.load_max_nudges(args.path)}")
375
- max_rounds, timeout = config.load_headless_limits(args.path)
381
+ print(f"supervision.max_nudges: {config.load_max_nudges(path)}")
382
+ max_rounds, timeout = config.load_headless_limits(path)
376
383
  if max_rounds is None and timeout is None:
377
384
  print(
378
385
  "headless: (unlimited — set headless.max_rounds/timeout or use --max-rounds/--timeout)"
@@ -381,7 +388,7 @@ def cmd_config(args: argparse.Namespace) -> int:
381
388
  print(
382
389
  f"headless: max_rounds={max_rounds or '(unlimited)'}, timeout={timeout or '(unlimited)'}s"
383
390
  )
384
- serve_rounds, serve_timeout = config.load_serve_limits(args.path)
391
+ serve_rounds, serve_timeout = config.load_serve_limits(path)
385
392
  if serve_rounds is None and serve_timeout is None:
386
393
  print("serve: (unlimited — set serve.max_rounds/timeout or use --max-rounds/--timeout)")
387
394
  else:
@@ -208,16 +208,16 @@ class Controller:
208
208
  return self.session.config_path
209
209
 
210
210
  @property
211
- def configured_context_path(self) -> str | None:
212
- return self.session._configured_context_path
211
+ def configured_context_paths(self) -> config.PathsArg:
212
+ return self.session._configured_context_paths
213
213
 
214
214
  @property
215
- def configured_agent_path(self) -> str | None:
216
- return self.session._configured_agent_path
215
+ def configured_agent_paths(self) -> config.PathsArg:
216
+ return self.session._configured_agent_paths
217
217
 
218
218
  @property
219
- def configured_command_path(self) -> str | None:
220
- return self.session._configured_command_path
219
+ def configured_command_paths(self) -> config.PathsArg:
220
+ return self.session._configured_command_paths
221
221
 
222
222
  @property
223
223
  def startup_warnings(self) -> list[str]:
@@ -271,10 +271,14 @@ class Controller:
271
271
 
272
272
  def clear_conversation(self) -> None:
273
273
  """Reset the conversation to empty (a new run generation)."""
274
- self.session.run_generation += 1
275
- self.session.last_messages = []
274
+ self.session.clear_conversation()
276
275
  self.conversation_history = []
277
- self.session.clear_todos()
276
+
277
+ def new_session(self) -> str | None:
278
+ """Save the current session and start a fresh one; return the saved path."""
279
+ saved = self.session.reset_conversation()
280
+ self.conversation_history = []
281
+ return saved
278
282
 
279
283
  # ------------------------------------------------------------------
280
284
  # run lifecycle
@@ -138,8 +138,15 @@ def apply_saved_session(controller: Controller, saved: SavedSession, report: Rep
138
138
  ``last_messages`` (what the views render). ``run_generation`` is
139
139
  bumped so a worker still winding down from a cancelled run cannot
140
140
  clobber the restored history with its salvaged one.
141
+
142
+ The replaced session's state (queued prompts, plan mode, todos,
143
+ context ratio, save state) is cleared first, as /clear does, which
144
+ also bumps ``run_generation``; the store reset drops a title request
145
+ still in flight for it.
141
146
  """
147
+ controller.clear_conversation()
142
148
  store = controller.store
149
+ store.reset()
143
150
  store.round_times = saved.round_times
144
151
  store.file_path = saved.path
145
152
  title = persistence.title_from_filename(saved.path)
@@ -147,7 +154,5 @@ def apply_saved_session(controller: Controller, saved: SavedSession, report: Rep
147
154
  store.title = title
148
155
  restore_agent(controller, saved.meta.get(AGENT_KEY), report)
149
156
  restore_model(controller, saved.meta.get(MODEL_KEY), report)
150
- controller.run_generation += 1
151
157
  controller.conversation_history = list(saved.messages)
152
158
  controller.last_messages = list(saved.messages)
153
- controller.clear_todos()
@@ -409,18 +409,6 @@ class ServerView(JsonlView):
409
409
  if state is not None:
410
410
  state.event.set()
411
411
 
412
- def reset_for_run(self, run_id: str | None) -> None:
413
- """Re-arm the view for a new run: fresh seq counter, new run_id."""
414
- with self._lock:
415
- self._buffer = []
416
- self._seq = 0
417
- self._sealed = False
418
- self._cancelled.clear()
419
- self.run_id = run_id
420
- self._deltas.reset()
421
- with self._pending_lock:
422
- self._abandoned = False
423
-
424
412
  # -- HeadlessView overrides -------------------------------------------------
425
413
 
426
414
  def confirm(self, prompt: str) -> bool:
@@ -450,15 +438,6 @@ class ServerView(JsonlView):
450
438
  )
451
439
  return self._wait_answer(state)
452
440
 
453
- # -- test seam ------------------------------------------------------------
454
-
455
- def take_pending(self) -> _AskState | None:
456
- """Detach the pending ask state (test inspection hook)."""
457
- with self._pending_lock:
458
- state = self._pending
459
- self._pending = None
460
- return state
461
-
462
441
 
463
442
  class AgentServer:
464
443
  """Request loop over stdin/stdout driving a resident Controller.
@@ -125,6 +125,7 @@ class SessionPersistence:
125
125
  self.file_path: str | None = None
126
126
  self.title_pending = False
127
127
  self._first_user_msg: str | None = None
128
+ self._generation = 0
128
129
  # wall-clock start times of each round, persisted in the
129
130
  # metadata block so restored sessions keep their round
130
131
  # timestamps (populated by the TUI on each run)
@@ -160,6 +161,53 @@ class SessionPersistence:
160
161
  self.file_path = self._unique_path(f"{proj_name}_{stamp}")
161
162
  return self.file_path
162
163
 
164
+ def reset(self) -> None:
165
+ """Forget the current session file so the next save starts a new one.
166
+
167
+ The file on disk stays restorable; the generation bump drops any
168
+ title request still in flight for the closed session.
169
+ """
170
+ with self._io_lock:
171
+ self._generation += 1
172
+ self.file_path = None
173
+ self.title = None
174
+ self.title_pending = False
175
+ self._first_user_msg = None
176
+ self.round_times = []
177
+
178
+ def clear_conversation_state(self) -> None:
179
+ """Drop per-conversation state but keep the file and title (/clear).
180
+
181
+ The generation bump stops an in-flight title request from
182
+ renaming the file after the cleared conversation.
183
+ """
184
+ with self._io_lock:
185
+ self._generation += 1
186
+ self._first_user_msg = None
187
+ self.round_times = []
188
+
189
+ def generation(self) -> int:
190
+ return self._generation
191
+
192
+ def begin_title_request(self) -> tuple[int, str] | None:
193
+ """Claim the one-shot title request: (generation, first message), or None.
194
+
195
+ Atomic with ``reset``: a reset landing between reading the
196
+ generation and setting ``title_pending`` would otherwise leave the
197
+ new session's flag stuck True (never titled).
198
+ """
199
+ with self._io_lock:
200
+ if self.title or self.title_pending or not self._first_user_msg:
201
+ return None
202
+ self.title_pending = True
203
+ return self._generation, self._first_user_msg
204
+
205
+ def clear_title_pending(self, generation: int) -> None:
206
+ """Clear ``title_pending`` only if GENERATION is still current."""
207
+ with self._io_lock:
208
+ if generation == self._generation:
209
+ self.title_pending = False
210
+
163
211
  def remember_first_user_message(self, text: str) -> None:
164
212
  if self._first_user_msg is None and len(text.strip()) > 3:
165
213
  self._first_user_msg = text.strip()[:500]
@@ -216,11 +264,14 @@ class SessionPersistence:
216
264
  os.replace(tmp, path)
217
265
  return path
218
266
 
219
- def apply_title(self, title: str) -> None:
220
- """Rename the session file to <title>_<TS>.md (never overwriting)."""
221
- # under the IO lock: the rename must not interleave with a
222
- # concurrent save's write+replace (see _io_lock)
267
+ def apply_title(self, title: str, generation: int | None = None) -> None:
268
+ """Rename the session file to <title>_<TS>.md (never overwriting).
269
+
270
+ A GENERATION that is no longer current (session reset) drops the title.
271
+ """
223
272
  with self._io_lock:
273
+ if generation is not None and generation != self._generation:
274
+ return
224
275
  title = sanitize_title(title)
225
276
  if not title:
226
277
  return
@@ -33,6 +33,7 @@ from .core import ( # noqa: F401
33
33
  discover_skills,
34
34
  find_agents_md_files,
35
35
  index_skills,
36
+ inject_tool_guidance,
36
37
  load_agent_prompt,
37
38
  load_context_files,
38
39
  load_task_completion_rules,