dostuff 0.2.10__tar.gz → 0.2.11__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 (176) hide show
  1. {dostuff-0.2.10 → dostuff-0.2.11}/PKG-INFO +13 -7
  2. {dostuff-0.2.10 → dostuff-0.2.11}/README.md +12 -6
  3. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/call_agent.py +32 -2
  4. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/instructions.py +15 -10
  5. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/loop.py +15 -5
  6. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/permissions.py +4 -0
  7. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/subagents/fork.py +1 -1
  8. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/subagents/prompt.py +2 -2
  9. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/cli_tui.py +104 -16
  10. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/headless.py +11 -5
  11. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/constants.py +5 -4
  12. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/consume_stream.py +14 -1
  13. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/context_usage.py +10 -3
  14. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/environment_context.py +1 -1
  15. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/manage_context.py +3 -0
  16. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/side_question.py +6 -9
  17. dostuff-0.2.11/dostuff/helpers/agent/turn_context.py +58 -0
  18. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/hooks/events.py +2 -7
  19. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/memory/export_session.py +3 -0
  20. dostuff-0.2.11/dostuff/helpers/skills/discover_skills.py +74 -0
  21. dostuff-0.2.11/dostuff/helpers/tools/resolve_safe_path.py +57 -0
  22. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/memory/session_store.py +6 -3
  23. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff.egg-info/PKG-INFO +13 -7
  24. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff.egg-info/SOURCES.txt +3 -0
  25. {dostuff-0.2.10 → dostuff-0.2.11}/pyproject.toml +1 -1
  26. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_cli_commands.py +26 -1
  27. dostuff-0.2.11/tests/test_export_session.py +27 -0
  28. dostuff-0.2.11/tests/test_file_tools.py +249 -0
  29. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_loop.py +212 -7
  30. dostuff-0.2.11/tests/test_optional_memory_and_instructions.py +196 -0
  31. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_permissions.py +58 -1
  32. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_roadmap_021.py +23 -0
  33. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_session_store.py +71 -0
  34. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_side_question.py +15 -16
  35. dostuff-0.2.11/tests/test_skills_discovery.py +230 -0
  36. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_subagents_fork.py +48 -4
  37. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_subagents_run.py +4 -0
  38. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_subagents_store.py +2 -3
  39. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_tui.py +572 -40
  40. dostuff-0.2.11/tests/test_turn_context.py +197 -0
  41. dostuff-0.2.10/dostuff/helpers/skills/discover_skills.py +0 -49
  42. dostuff-0.2.10/dostuff/helpers/tools/resolve_safe_path.py +0 -33
  43. dostuff-0.2.10/tests/test_file_tools.py +0 -116
  44. dostuff-0.2.10/tests/test_optional_memory_and_instructions.py +0 -85
  45. dostuff-0.2.10/tests/test_skills_discovery.py +0 -37
  46. {dostuff-0.2.10 → dostuff-0.2.11}/LICENSE +0 -0
  47. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/__init__.py +0 -0
  48. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/__main__.py +0 -0
  49. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/run_tool.py +0 -0
  50. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/subagents/__init__.py +0 -0
  51. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/subagents/adapter.py +0 -0
  52. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/subagents/definitions.py +0 -0
  53. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/subagents/registry.py +0 -0
  54. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/agent/subagents/run.py +0 -0
  55. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/cli.py +0 -0
  56. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/config.py +0 -0
  57. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/append_step.py +0 -0
  58. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/file_mentions.py +0 -0
  59. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/get_model_token_limit.py +0 -0
  60. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/load_identity.py +0 -0
  61. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/load_project_instructions.py +0 -0
  62. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/loop_check_cancelled.py +0 -0
  63. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/loop_emit.py +0 -0
  64. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/model_cost.py +0 -0
  65. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/notices.py +0 -0
  66. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/pastes.py +0 -0
  67. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/quick_memory.py +0 -0
  68. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/slash_suggestion.py +0 -0
  69. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/steering.py +0 -0
  70. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/agent/tool_output.py +0 -0
  71. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/hooks/__init__.py +0 -0
  72. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/hooks/dispatch.py +0 -0
  73. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/hooks/load_hooks.py +0 -0
  74. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/hooks/run_hook.py +0 -0
  75. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/hooks/trust.py +0 -0
  76. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/mcp/load_mcp_config.py +0 -0
  77. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/mcp/mcp_oauth.py +0 -0
  78. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/mcp/server_config.py +0 -0
  79. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/mcp/token_store.py +0 -0
  80. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/memory/resolve_memory_operation.py +0 -0
  81. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/memory/shell_step.py +0 -0
  82. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/models/add_model_entry.py +0 -0
  83. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/models/list_models.py +0 -0
  84. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/models/opencode.py +0 -0
  85. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/skills/custom_commands.py +0 -0
  86. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/skills/skill_command.py +0 -0
  87. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/tools/diff.py +0 -0
  88. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/tools/generate_tool_schema.py +0 -0
  89. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/tools/project_root.py +0 -0
  90. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/ui/__init__.py +0 -0
  91. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/ui/ask_answers.py +0 -0
  92. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/ui/doctor.py +0 -0
  93. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/ui/emit.py +0 -0
  94. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/ui/prompt_history.py +0 -0
  95. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/ui/terminal_signals.py +0 -0
  96. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/helpers/ui/tools_listing.py +0 -0
  97. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/checkpoints.py +0 -0
  98. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/exceptions.py +0 -0
  99. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/mcp/mcp_client.py +0 -0
  100. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/mcp/mcp_client_registration_store.py +0 -0
  101. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/mcp/mcp_tool_registry_store.py +0 -0
  102. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/memory/chroma.py +0 -0
  103. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/memory/episodic_memory_store.py +0 -0
  104. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/memory/semantic_memory_store.py +0 -0
  105. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/memory/stores.py +0 -0
  106. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/memory/types.py +0 -0
  107. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/model.py +0 -0
  108. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/tracing.py +0 -0
  109. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/lib/worktree.py +0 -0
  110. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/memory/__init__.py +0 -0
  111. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/setup_wizard.py +0 -0
  112. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/skills.py +0 -0
  113. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/templates/config.example.yaml +0 -0
  114. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/templates/env.example +0 -0
  115. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/__init__.py +0 -0
  116. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/agent.py +0 -0
  117. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/ask_user.py +0 -0
  118. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/bash/bash_command.py +0 -0
  119. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/bash/bash_output.py +0 -0
  120. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/bash/jobs.py +0 -0
  121. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/bash/kill_shell.py +0 -0
  122. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/create_agent_type.py +0 -0
  123. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/definitions.py +0 -0
  124. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/files/delete_file.py +0 -0
  125. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/files/edit_file.py +0 -0
  126. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/files/list_files.py +0 -0
  127. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/files/read_file.py +0 -0
  128. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/files/write_file.py +0 -0
  129. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/get_current_datetime.py +0 -0
  130. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/mcp/call_mcp_tool.py +0 -0
  131. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/mcp/get_mcp_tool_details.py +0 -0
  132. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/mcp/search_mcp_tools.py +0 -0
  133. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/memory/save_episode.py +0 -0
  134. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/memory/save_memory.py +0 -0
  135. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/names.py +0 -0
  136. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/search/glob.py +0 -0
  137. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/search/grep.py +0 -0
  138. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/search/walk.py +0 -0
  139. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/send_message.py +0 -0
  140. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/settings.py +0 -0
  141. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/stop_agent.py +0 -0
  142. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/todo_write.py +0 -0
  143. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/web_fetch.py +0 -0
  144. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff/tools/web_search.py +0 -0
  145. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff.egg-info/dependency_links.txt +0 -0
  146. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff.egg-info/entry_points.txt +0 -0
  147. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff.egg-info/requires.txt +0 -0
  148. {dostuff-0.2.10 → dostuff-0.2.11}/dostuff.egg-info/top_level.txt +0 -0
  149. {dostuff-0.2.10 → dostuff-0.2.11}/setup.cfg +0 -0
  150. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_ask_user.py +0 -0
  151. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_bash_command.py +0 -0
  152. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_checkpoints_todos_caching.py +0 -0
  153. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_config_memory_mcp.py +0 -0
  154. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_create_agent_type.py +0 -0
  155. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_file_mentions.py +0 -0
  156. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_hooks.py +0 -0
  157. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_jobs.py +0 -0
  158. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_mcp_e2e.py +0 -0
  159. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_mcp_oauth.py +0 -0
  160. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_opencode.py +0 -0
  161. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_pastes.py +0 -0
  162. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_settings_tools.py +0 -0
  163. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_setup_wizard.py +0 -0
  164. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_side_question_litellm.py +0 -0
  165. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_skill_command.py +0 -0
  166. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_slash_suggestion.py +0 -0
  167. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_steering.py +0 -0
  168. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_subagent.py +0 -0
  169. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_subagents_background.py +0 -0
  170. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_subagents_types.py +0 -0
  171. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_terminal_signals.py +0 -0
  172. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_tool_schemas.py +0 -0
  173. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_tools_listing.py +0 -0
  174. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_web_fetch.py +0 -0
  175. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_web_search.py +0 -0
  176. {dostuff-0.2.10 → dostuff-0.2.11}/tests/test_worktree.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dostuff
3
- Version: 0.2.10
3
+ Version: 0.2.11
4
4
  Summary: DoStuff - a terminal coding agent for any LLM: TUI and headless mode, permissions, MCP, skills, web tools, sessions and git worktrees
5
5
  Author-email: Varun Kumawat <varunkumawatleap2@gmail.com>
6
6
  License-Expression: MIT
@@ -89,7 +89,7 @@ DoStuff is a terminal AI agent that runs anywhere `pip` runs. It gives you a ful
89
89
  - **Permission layer** — mutating tool calls ask for approval (allow once / always this session / deny with a note); read-only shell commands run without asking; modes `ask` / `allowlist` / `auto`; `/undo` reverts the agent's file changes
90
90
  - **Hooks** — shell commands on `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`, `SubagentStart` and `SubagentStop` that can block a tool call or prompt, feed a formatter's output back to the model, or keep the turn going; Claude Code's hook I/O contract, and project hooks run only once you trust them. See [Hooks](#hooks)
91
91
  - **Background jobs** — `bash_command(run_in_background=true)` starts dev servers, watchers and long test runs as jobs the agent reads with `bash_output` (`wait_for` a ready line) and stops with `kill_shell`; it hears when one ends. `Ctrl+B` moves a running command to the background, `/jobs` lists them, and none outlives the session. See [Background jobs](#background-jobs)
92
- - **File sandbox** — file tools stay inside the project directory and never read `.env*` files or `~/.dostuff/`
92
+ - **File sandbox** — file tools stay inside the project directory, plus read-only access to discovered skill folders, and never read `.env*` files or the rest of `~/.dostuff/`
93
93
  - **Skills loader** — drop a `SKILL.md` in the right folder, restart, done; run one with `/<skill-name> [args]`
94
94
  - **Subagents** — the `agent` tool starts agents in parallel, in the foreground or the background, from built-in types (`explore`, `plan`, `general-purpose`), your own Markdown agent files (Claude Code's `.claude/agents/` work too) or a `fork` of the conversation; continue one with `send_message`, stop it with `stop_agent`, see them all in `/agents`. See [Subagents](#subagents)
95
95
  - **Per-tool timeout** (120s) to prevent hung servers; long tool output is truncated (head + tail) before it reaches the model
@@ -250,7 +250,7 @@ In the TUI:
250
250
  | `/model [<provider/model>] [--active]` | Pick a model: your saved ones (`models:` in config.yaml) first, then "More <provider> models…" for each provider's list (type to filter; Enter on no match uses what you typed). A model that isn't saved yet is added to `~/.dostuff/config.yaml`. A plain `/model` switch lasts only for this session; add `--active` (e.g. `/model --active`, or `/model anthropic/claude-sonnet-5-5 --active`) to make it the default that new sessions start with |
251
251
  | `/config [mcp] [project]` | Edit a settings file right in the TUI: pick `config.yaml` or the MCP servers, user (`~/.dostuff`) or project (`./.dostuff`), or name one (`/config mcp project`). `Ctrl+S` checks the file, saves it and applies it without a restart (an invalid file stays open with the error); `Esc` closes, twice if there are unsaved changes. A new file starts with every option commented out. `.env` files aren't offered |
252
252
  | `/status` | Session, directory, model, permission mode, tokens, context use, MCP servers |
253
- | `/context` | What fills the context window: system prompt, tools, MCP tools, project instructions, compaction summary and messages, with tokens, % and a bar |
253
+ | `/context` | What fills the context window: system prompt, turn context (the environment, recalled memories and hook context sent with each prompt), tools, MCP tools, project instructions, compaction summary and messages, with tokens, % and a bar |
254
254
  | `/memory [project\|global]` | Edit `AGENTS.md` (this project's or `~/.dostuff/AGENTS.md`) in the same editor as `/config`; `Ctrl+S` saves and the agent follows it from the next message |
255
255
  | `/doctor` | The `dostuff doctor` checks (config, API key, MCP config, memory, hooks), with a fix for each problem |
256
256
  | `/tools` | Every tool the agent has: when it asks (in `ask` mode), whether subagents get it and what it does, then each connected MCP server's tools (reached through `call_mcp_tool`) |
@@ -273,6 +273,7 @@ In the TUI:
273
273
  **Visual elements:**
274
274
 
275
275
  - **Messages** — `>` for your prompts (on a grey band), `●` for agent replies and tool calls, `⎿` for tool results; the terminal background shows through
276
+ - **Sticky prompt** — once a prompt or `!command` scrolls off the top, it stays pinned there on one row while you are in its turn, as the answer streams or when you scroll back through an old one, until the next prompt reaches the top. Click it to go back to the start of the turn; `↓ Jump to bottom` returns you to the latest message
276
277
  - **Approvals** — a selector (arrows, a number, or `y` = allow once, `a` = always this session, `n` = deny with an optional note); several calls in one response can be approved together
277
278
  - **Turn summary** — `✻ Worked for 1m 5s · $0.01 · done 12:59 PM` after each turn
278
279
  - **Diffs** — `write_file` / `edit_file` changes shown as a coloured diff
@@ -333,7 +334,8 @@ API keys stay in `.env` files, which the agent can't read or change. Subagents d
333
334
 
334
335
  > [!IMPORTANT]
335
336
  > File tools are sandboxed to the project directory (the directory the session runs in): paths that resolve
336
- > outside it are rejected, and `.env*` files and `~/.dostuff/` cannot be read. **The shell is not sandboxed**:
337
+ > outside it are rejected, except that discovered skill folders can be read (never written), and `.env*` files and
338
+ > the rest of `~/.dostuff/` cannot be read. **The shell is not sandboxed**:
337
339
  > `bash_command` can touch anything your user can, which is why non-read-only commands ask first.
338
340
  > The shell is Git Bash / `bash` when found, otherwise PowerShell on Windows or `/bin/sh`.
339
341
 
@@ -568,7 +570,7 @@ both modes: a skill is a turn's prompt, not a correction.
568
570
  order you sent them, so a message holding a big file never jumps ahead of the one after it. The `Attached …` lines
569
571
  show as they finish, as for a prompt.
570
572
  - **Hooks and the sandbox still apply**: `UserPromptSubmit` runs for each correction at the boundary, so a hook can
571
- block it — it is shown like a blocked prompt and never reaches the model — or add context for this turn, written as a
573
+ block it — it is shown like a blocked prompt and never reaches the model — or add context, written as a
572
574
  note right before the correction (the system prompt never changes mid-turn, so the prompt cache holds); a preparation
573
575
  failure is reported instead of half-delivered.
574
576
 
@@ -718,7 +720,7 @@ matcher and tool argument names are renamed (see [the table below](#coming-from-
718
720
  | Event | When | Matcher is matched against | What a hook can do |
719
721
  |---|---|---|---|
720
722
  | `SessionStart` | Before the first turn of a session, and after a compaction | the source: `startup`, `resume`, `clear`, `compact` | Add context for the rest of the session |
721
- | `UserPromptSubmit` | After you send a prompt, before it is stored or sent | — | Reject the prompt, or add context for this turn |
723
+ | `UserPromptSubmit` | After you send a prompt, before it is stored or sent | — | Reject the prompt, or add context sent with it (hidden from the transcript, and stays in the model's history) |
722
724
  | `PreToolUse` | Before each tool call, before any approval prompt | the tool name | `allow`, `deny` or `ask`; rewrite the arguments |
723
725
  | `PostToolUse` | After a tool call ran | the tool name | Append text to the result the model sees |
724
726
  | `Stop` | When the agent is about to give its final answer | — | Block, so the turn continues with your reason |
@@ -1090,7 +1092,11 @@ Skills are directories containing a `SKILL.md` (frontmatter with `name` and `des
1090
1092
  4. `~/.agents/skills/`
1091
1093
  5. `<cwd>/skills/`
1092
1094
 
1093
- **Conflict resolution:** No deduplication in the system prompt. If two skills share the same name (from different directories), both are loaded and passed to the model — the agent may see the same skill twice with different `location` paths. To avoid confusion, keep names unique across the search paths.
1095
+ **Conflict resolution:** Skills are deduplicated by name: if two share a name, the first one found (in the order above) wins and the other is dropped, from the system prompt and from the slash commands alike.
1096
+
1097
+ **How a skill reaches the model:** the system prompt lists each skill's `name`, `description` and `dir` (its absolute folder), and only those. When the model decides to use a skill it reads the `SKILL.md` in that dir with `read_file`, so a body costs nothing until it is needed. Frontmatter is parsed as YAML, so quoted and folded (`>`, `|`) descriptions arrive as plain text; a file with invalid YAML still loads, with its fields read line by line.
1098
+
1099
+ File tools can read a discovered skill's folder wherever it lives, including the files next to `SKILL.md` (`scripts/`, `reference/`), but never write there. `.env*` files stay unreadable inside a skill folder too, and of `~/.dostuff/` only discovered skills under `~/.dostuff/skills/` can be read.
1094
1100
 
1095
1101
  **Example structure:**
1096
1102
 
@@ -41,7 +41,7 @@ DoStuff is a terminal AI agent that runs anywhere `pip` runs. It gives you a ful
41
41
  - **Permission layer** — mutating tool calls ask for approval (allow once / always this session / deny with a note); read-only shell commands run without asking; modes `ask` / `allowlist` / `auto`; `/undo` reverts the agent's file changes
42
42
  - **Hooks** — shell commands on `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`, `SubagentStart` and `SubagentStop` that can block a tool call or prompt, feed a formatter's output back to the model, or keep the turn going; Claude Code's hook I/O contract, and project hooks run only once you trust them. See [Hooks](#hooks)
43
43
  - **Background jobs** — `bash_command(run_in_background=true)` starts dev servers, watchers and long test runs as jobs the agent reads with `bash_output` (`wait_for` a ready line) and stops with `kill_shell`; it hears when one ends. `Ctrl+B` moves a running command to the background, `/jobs` lists them, and none outlives the session. See [Background jobs](#background-jobs)
44
- - **File sandbox** — file tools stay inside the project directory and never read `.env*` files or `~/.dostuff/`
44
+ - **File sandbox** — file tools stay inside the project directory, plus read-only access to discovered skill folders, and never read `.env*` files or the rest of `~/.dostuff/`
45
45
  - **Skills loader** — drop a `SKILL.md` in the right folder, restart, done; run one with `/<skill-name> [args]`
46
46
  - **Subagents** — the `agent` tool starts agents in parallel, in the foreground or the background, from built-in types (`explore`, `plan`, `general-purpose`), your own Markdown agent files (Claude Code's `.claude/agents/` work too) or a `fork` of the conversation; continue one with `send_message`, stop it with `stop_agent`, see them all in `/agents`. See [Subagents](#subagents)
47
47
  - **Per-tool timeout** (120s) to prevent hung servers; long tool output is truncated (head + tail) before it reaches the model
@@ -202,7 +202,7 @@ In the TUI:
202
202
  | `/model [<provider/model>] [--active]` | Pick a model: your saved ones (`models:` in config.yaml) first, then "More <provider> models…" for each provider's list (type to filter; Enter on no match uses what you typed). A model that isn't saved yet is added to `~/.dostuff/config.yaml`. A plain `/model` switch lasts only for this session; add `--active` (e.g. `/model --active`, or `/model anthropic/claude-sonnet-5-5 --active`) to make it the default that new sessions start with |
203
203
  | `/config [mcp] [project]` | Edit a settings file right in the TUI: pick `config.yaml` or the MCP servers, user (`~/.dostuff`) or project (`./.dostuff`), or name one (`/config mcp project`). `Ctrl+S` checks the file, saves it and applies it without a restart (an invalid file stays open with the error); `Esc` closes, twice if there are unsaved changes. A new file starts with every option commented out. `.env` files aren't offered |
204
204
  | `/status` | Session, directory, model, permission mode, tokens, context use, MCP servers |
205
- | `/context` | What fills the context window: system prompt, tools, MCP tools, project instructions, compaction summary and messages, with tokens, % and a bar |
205
+ | `/context` | What fills the context window: system prompt, turn context (the environment, recalled memories and hook context sent with each prompt), tools, MCP tools, project instructions, compaction summary and messages, with tokens, % and a bar |
206
206
  | `/memory [project\|global]` | Edit `AGENTS.md` (this project's or `~/.dostuff/AGENTS.md`) in the same editor as `/config`; `Ctrl+S` saves and the agent follows it from the next message |
207
207
  | `/doctor` | The `dostuff doctor` checks (config, API key, MCP config, memory, hooks), with a fix for each problem |
208
208
  | `/tools` | Every tool the agent has: when it asks (in `ask` mode), whether subagents get it and what it does, then each connected MCP server's tools (reached through `call_mcp_tool`) |
@@ -225,6 +225,7 @@ In the TUI:
225
225
  **Visual elements:**
226
226
 
227
227
  - **Messages** — `>` for your prompts (on a grey band), `●` for agent replies and tool calls, `⎿` for tool results; the terminal background shows through
228
+ - **Sticky prompt** — once a prompt or `!command` scrolls off the top, it stays pinned there on one row while you are in its turn, as the answer streams or when you scroll back through an old one, until the next prompt reaches the top. Click it to go back to the start of the turn; `↓ Jump to bottom` returns you to the latest message
228
229
  - **Approvals** — a selector (arrows, a number, or `y` = allow once, `a` = always this session, `n` = deny with an optional note); several calls in one response can be approved together
229
230
  - **Turn summary** — `✻ Worked for 1m 5s · $0.01 · done 12:59 PM` after each turn
230
231
  - **Diffs** — `write_file` / `edit_file` changes shown as a coloured diff
@@ -285,7 +286,8 @@ API keys stay in `.env` files, which the agent can't read or change. Subagents d
285
286
 
286
287
  > [!IMPORTANT]
287
288
  > File tools are sandboxed to the project directory (the directory the session runs in): paths that resolve
288
- > outside it are rejected, and `.env*` files and `~/.dostuff/` cannot be read. **The shell is not sandboxed**:
289
+ > outside it are rejected, except that discovered skill folders can be read (never written), and `.env*` files and
290
+ > the rest of `~/.dostuff/` cannot be read. **The shell is not sandboxed**:
289
291
  > `bash_command` can touch anything your user can, which is why non-read-only commands ask first.
290
292
  > The shell is Git Bash / `bash` when found, otherwise PowerShell on Windows or `/bin/sh`.
291
293
 
@@ -520,7 +522,7 @@ both modes: a skill is a turn's prompt, not a correction.
520
522
  order you sent them, so a message holding a big file never jumps ahead of the one after it. The `Attached …` lines
521
523
  show as they finish, as for a prompt.
522
524
  - **Hooks and the sandbox still apply**: `UserPromptSubmit` runs for each correction at the boundary, so a hook can
523
- block it — it is shown like a blocked prompt and never reaches the model — or add context for this turn, written as a
525
+ block it — it is shown like a blocked prompt and never reaches the model — or add context, written as a
524
526
  note right before the correction (the system prompt never changes mid-turn, so the prompt cache holds); a preparation
525
527
  failure is reported instead of half-delivered.
526
528
 
@@ -670,7 +672,7 @@ matcher and tool argument names are renamed (see [the table below](#coming-from-
670
672
  | Event | When | Matcher is matched against | What a hook can do |
671
673
  |---|---|---|---|
672
674
  | `SessionStart` | Before the first turn of a session, and after a compaction | the source: `startup`, `resume`, `clear`, `compact` | Add context for the rest of the session |
673
- | `UserPromptSubmit` | After you send a prompt, before it is stored or sent | — | Reject the prompt, or add context for this turn |
675
+ | `UserPromptSubmit` | After you send a prompt, before it is stored or sent | — | Reject the prompt, or add context sent with it (hidden from the transcript, and stays in the model's history) |
674
676
  | `PreToolUse` | Before each tool call, before any approval prompt | the tool name | `allow`, `deny` or `ask`; rewrite the arguments |
675
677
  | `PostToolUse` | After a tool call ran | the tool name | Append text to the result the model sees |
676
678
  | `Stop` | When the agent is about to give its final answer | — | Block, so the turn continues with your reason |
@@ -1042,7 +1044,11 @@ Skills are directories containing a `SKILL.md` (frontmatter with `name` and `des
1042
1044
  4. `~/.agents/skills/`
1043
1045
  5. `<cwd>/skills/`
1044
1046
 
1045
- **Conflict resolution:** No deduplication in the system prompt. If two skills share the same name (from different directories), both are loaded and passed to the model — the agent may see the same skill twice with different `location` paths. To avoid confusion, keep names unique across the search paths.
1047
+ **Conflict resolution:** Skills are deduplicated by name: if two share a name, the first one found (in the order above) wins and the other is dropped, from the system prompt and from the slash commands alike.
1048
+
1049
+ **How a skill reaches the model:** the system prompt lists each skill's `name`, `description` and `dir` (its absolute folder), and only those. When the model decides to use a skill it reads the `SKILL.md` in that dir with `read_file`, so a body costs nothing until it is needed. Frontmatter is parsed as YAML, so quoted and folded (`>`, `|`) descriptions arrive as plain text; a file with invalid YAML still loads, with its fields read line by line.
1050
+
1051
+ File tools can read a discovered skill's folder wherever it lives, including the files next to `SKILL.md` (`scripts/`, `reference/`), but never write there. `.env*` files stay unreadable inside a skill folder too, and of `~/.dostuff/` only discovered skills under `~/.dostuff/skills/` can be read.
1046
1052
 
1047
1053
  **Example structure:**
1048
1054
 
@@ -8,7 +8,7 @@ from dostuff.lib.tracing import content_attr, tracer
8
8
  from opentelemetry.trace import Status, StatusCode
9
9
 
10
10
 
11
- # Two breakpoints: the system prompt (tools + instructions, stable within a turn) and the last
11
+ # Two breakpoints: the system prompt (tools + instructions, stable across turns) and the last
12
12
  # message, which moves each call, so the next call reads everything before it from the cache.
13
13
  CACHE_BREAKPOINTS: list[dict[str, Any]] = [
14
14
  {"location": "message", "role": "system"},
@@ -39,11 +39,41 @@ def build_request_kwargs(stream: bool) -> dict[str, Any]:
39
39
  return kwargs
40
40
 
41
41
 
42
+ def _as_blocks(content: Any) -> list[Any]:
43
+ if isinstance(content, list):
44
+ return content
45
+ return [{"type": "text", "text": content}] if content else []
46
+
47
+
48
+ def _join_user_content(first: Any, second: Any) -> Any:
49
+ if isinstance(first, list) or isinstance(second, list):
50
+ return _as_blocks(first) + _as_blocks(second) # an image block must survive, so no flattening to text
51
+ return "\n\n".join(text for text in (first, second) if text)
52
+
53
+
54
+ def provider_messages(steps: list[dict[str, Any]]) -> list[dict[str, Any]]:
55
+ """The history as a provider may see it. The steps themselves are left alone: the store and every reader need
56
+ them apart, while a request needs valid turns.
57
+
58
+ `meta` is dostuff's own (the turn-context marker), so it is dropped. Adjacent user steps become one message,
59
+ because Perplexity and strict chat templates (vLLM's Gemma, Mistral) reject two in a row, and a turn's context
60
+ step always sits right before its prompt. Same history, same result, so the cached prefix holds.
61
+ """
62
+ messages: list[dict[str, Any]] = []
63
+ for step in steps:
64
+ message = {k: v for k, v in step.items() if k != "meta"} if "meta" in step else step
65
+ if messages and message.get("role") == "user" and messages[-1].get("role") == "user":
66
+ messages[-1] = {**messages[-1], "content": _join_user_content(messages[-1].get("content"), message.get("content"))}
67
+ else:
68
+ messages.append(message)
69
+ return messages
70
+
71
+
42
72
  async def call_agent(steps_history: list, system_instruction: str, tool_names: list[str] | None = None, stream: bool = False):
43
73
  if tool_names is None:
44
74
  tool_names = default_tool_names()
45
75
  active_schemas = [TOOL_SCHEMAS[name] for name in tool_names if name in TOOL_SCHEMAS]
46
- messages = [{"role": "system", "content": system_instruction}] + steps_history
76
+ messages = [{"role": "system", "content": system_instruction}] + provider_messages(steps_history)
47
77
  request = build_request_kwargs(stream)
48
78
 
49
79
  span = tracer.start_span("model_call")
@@ -1,4 +1,4 @@
1
- """System prompt for a turn, shared by the TUI and `dostuff -p` (headless)."""
1
+ """The system prompt and the per-turn context, shared by the TUI and `dostuff -p` (headless)."""
2
2
  import asyncio
3
3
  from pathlib import Path
4
4
  from typing import Any
@@ -10,6 +10,7 @@ from dostuff.helpers.agent.constants import (
10
10
  from dostuff.helpers.agent.environment_context import build_environment_block
11
11
  from dostuff.helpers.agent.load_identity import load_identity
12
12
  from dostuff.helpers.agent.load_project_instructions import load_project_instructions
13
+ from dostuff.helpers.agent.turn_context import compose_turn_context
13
14
  from dostuff.helpers.skills.discover_skills import discover_skills
14
15
  from dostuff.helpers.ui.emit import emit
15
16
  from dostuff.lib.memory import chroma
@@ -26,7 +27,7 @@ def _background_wait(interactive: bool) -> str:
26
27
  def skills_summary(skills: list[dict[str, Any]]) -> str:
27
28
  """The skills list as the system prompt shows it."""
28
29
  summary = "\n\n".join(
29
- f"- name: {s['name']}\n description: {s['description']}\n location: {s['location']}"
30
+ f"- name: {s['name']}\n description: {s['description']}\n dir: {s['dir']}"
30
31
  for s in skills
31
32
  )
32
33
  return summary or "(none available)"
@@ -67,8 +68,16 @@ def build_base_instructions(interactive: bool = False) -> tuple[str, list[dict[s
67
68
  return instructions, skills
68
69
 
69
70
 
70
- async def build_turn_instructions(base: str, user_text: str, memory_store: Any, episodic_store: Any, user_id: str) -> str:
71
- """Base instructions + the environment block + memories and past episodes relevant to user_text.
71
+ def build_system_instructions(base: str) -> str:
72
+ """The system prompt of every turn: `base`, byte for byte. Anything that changes per turn goes in
73
+ `build_turn_context` instead: one differing byte here invalidates the provider's whole cached prefix."""
74
+ return base
75
+
76
+
77
+ async def build_turn_context(user_text: str, *, memory_store: Any, episodic_store: Any, user_id: str,
78
+ prompt_context: str = "") -> str:
79
+ """The turn's hidden context step: the environment block, memories and past episodes relevant to user_text,
80
+ and UserPromptSubmit context.
72
81
 
73
82
  The stores are None when long-term memory is off (chromadb not installed): no recall then.
74
83
  """
@@ -98,9 +107,5 @@ async def build_turn_instructions(base: str, user_text: str, memory_store: Any,
98
107
  for ep in episodes
99
108
  )
100
109
 
101
- instructions = base + "\n\n" + await asyncio.to_thread(build_environment_block)
102
- if memory_text:
103
- instructions += f"\n\n<relevant_user_facts>\n{memory_text}\n</relevant_user_facts>"
104
- if episodic_text:
105
- instructions += f"\n\n<past_episodes>\n{episodic_text}\n</past_episodes>"
106
- return instructions
110
+ environment = await asyncio.to_thread(build_environment_block)
111
+ return compose_turn_context(environment, memory_text, episodic_text, prompt_context)
@@ -13,7 +13,7 @@ import asyncio
13
13
  import inspect
14
14
  import random
15
15
  from dataclasses import dataclass
16
- from dostuff.agent.permissions import SessionPermissions
16
+ from dostuff.agent.permissions import PLAN_MODE_INSTRUCTION, PLAN_MODE_OFF_INSTRUCTION, SessionPermissions
17
17
  from dostuff.agent.run_tool import (
18
18
  CANCELLED_RESULT, authorize_batch, authorize_tool, dispatch_tool, post_tool_use, pre_tool_use,
19
19
  )
@@ -28,6 +28,7 @@ from dostuff.tools.definitions import TOOL_MAP, default_tool_names
28
28
  from dostuff.agent.subagents.fork import ForkContext
29
29
  from dostuff.helpers.agent.notices import format_notices, get_notice_queue
30
30
  from dostuff.helpers.agent.steering import SteerMessage, SteeringQueue, frame_steered
31
+ from dostuff.helpers.agent.turn_context import PROMPT_CONTEXT_HEADER, delivered_plan_mode, make_plan_mode_step
31
32
  from dostuff.helpers.agent.side_question import (
32
33
  compose_system_instruction, plan_mode_on, publish_snapshot, published_snapshot, usage_dict as build_usage_dict,
33
34
  )
@@ -254,6 +255,16 @@ async def loop(session_id: str, turn_id: str, user_text: str, dynamic_system_ins
254
255
  framed steering message."""
255
256
  await append_step({"role": "user", "content": text}, steps_history, working_history, current_session_history, session_id, store, turn_type)
256
257
 
258
+ async def sync_plan_mode() -> None:
259
+ """Tell the model when plan mode differs from what the history last said (D11). Read before each call,
260
+ since the mode can change mid-turn (Shift+Tab); the system prompt never changes for it, so the cache holds."""
261
+ plan_mode = plan_mode_on(permissions, config)
262
+ if plan_mode == delivered_plan_mode(working_history):
263
+ return
264
+ step = make_plan_mode_step(plan_mode, PLAN_MODE_INSTRUCTION if plan_mode else PLAN_MODE_OFF_INSTRUCTION)
265
+ await append_step(step, steps_history, working_history, current_session_history, session_id, store, turn_type)
266
+ publish_snapshot(session_id, fork_context())
267
+
257
268
  async def deliver_steer(messages: list[SteerMessage]) -> int:
258
269
  """D6's drain body, shared by the top-of-iteration drain and D7's final-answer path: a failed
259
270
  or blocked message is reported and appended nowhere, the rest is written framed and once
@@ -279,7 +290,7 @@ async def loop(session_id: str, turn_id: str, user_text: str, dynamic_system_ins
279
290
  if context:
280
291
  # In-band note, not a system fold: a mid-turn system change would invalidate the
281
292
  # provider's whole cached prefix — the system prompt stays byte-stable in a turn.
282
- await append_note(f"[Context from UserPromptSubmit hooks]\n{context}")
293
+ await append_note(f"{PROMPT_CONTEXT_HEADER}\n{context}")
283
294
  await append_note(frame_steered(steer_msg.content)) # the steer message's only write (CON-004), framed (D6)
284
295
  await loop_emit("steered", {"id": steer_msg.id, "index": len(steps_history) - 1},
285
296
  adapter=adapter)
@@ -353,13 +364,12 @@ async def loop(session_id: str, turn_id: str, user_text: str, dynamic_system_ins
353
364
  while True:
354
365
  model_span = None
355
366
  progress = StreamProgress()
367
+ await sync_plan_mode() # here, so a retry after an overflow compaction is covered too
356
368
  try:
357
- # Read per call: the mode can change mid-turn (Shift+Tab)
358
- plan_mode = plan_mode_on(permissions, config)
359
369
  interaction, model_span = await call_agent(
360
370
  steps_history=working_history,
361
371
  system_instruction=compose_system_instruction(
362
- dynamic_system_instruction, plan_mode, compaction_notes, session_hook_context),
372
+ dynamic_system_instruction, compaction_notes, session_hook_context),
363
373
  tool_names=tool_names,
364
374
  stream=stream,
365
375
  )
@@ -43,6 +43,10 @@ PLAN_MODE_INSTRUCTION = (
43
43
  "concrete step-by-step plan. In plan mode, ask what you need *before* writing the plan, with "
44
44
  "`ask_user` — not after. Don't make the changes until the user leaves plan mode (Shift+Tab or /permissions)."
45
45
  )
46
+ PLAN_MODE_OFF_INSTRUCTION = (
47
+ "## Plan mode\nPlan mode is off: the earlier plan-mode restrictions no longer apply. Normal permission checks "
48
+ "do, so you can make changes now."
49
+ )
46
50
 
47
51
 
48
52
  def next_mode(mode: str) -> str:
@@ -23,7 +23,7 @@ NO_CONVERSATION = ("[error] A fork copies the main agent's conversation, and the
23
23
  class ForkContext:
24
24
  """What a fork inherits from the main agent's loop at the moment of the call (D11). `loop()` builds it and
25
25
  `dispatch_tool` injects it into `agent` and `send_message` as the `fork_context` harness param."""
26
- system_instruction: str # the main turn's dynamic system instruction (before plan mode and notes)
26
+ system_instruction: str # the main turn's dynamic system instruction (before the notes)
27
27
  compaction_notes: str
28
28
  history: list[dict[str, Any]] # a copy of the main working history, without the in-flight assistant step
29
29
  tool_names: list[str] # the main agent's tools
@@ -40,8 +40,8 @@ def _sections(agent_def: "AgentDef", worktree: Worktree | None) -> str:
40
40
  project = project_instructions_section(project_root())
41
41
  if project:
42
42
  parts.append(project)
43
- parts.append("Available skills (read the full SKILL.md at the given path before using one):\n"
44
- + skills_summary(discover_skills()))
43
+ parts.append("Available skills (before using one, read the SKILL.md in its dir; the files it refers to are "
44
+ "relative to that dir):\n" + skills_summary(discover_skills()))
45
45
  return "\n\n".join(parts)
46
46
 
47
47
 
@@ -34,7 +34,7 @@ from textual.events import Click, Key, Paste, TextSelected
34
34
  from dostuff import __version__
35
35
  from dostuff.config import NOTIFY_KINDS, STATUS_BAR_ITEMS, get_config, parse_compact_threshold
36
36
  from dostuff.agent.permissions import PERMISSION_MODES, ApprovalReply, SessionPermissions, next_mode, parse_answer
37
- from dostuff.agent.instructions import build_base_instructions, build_turn_instructions
37
+ from dostuff.agent.instructions import build_base_instructions, build_system_instructions, build_turn_context
38
38
  from dostuff.helpers.agent.constants import COMMAND_DESCRIPTIONS, COMMAND_FLAGS
39
39
  from dostuff.helpers.memory.export_session import session_to_markdown
40
40
  from dostuff.helpers.memory.shell_step import format_shell_step as _format_shell_step, parse_shell_step as _parse_shell_step
@@ -59,18 +59,19 @@ from dostuff.helpers.agent.pastes import PasteStore, sweep_old_pastes
59
59
  from dostuff.helpers.agent.steering import SteerMessage, SteeringQueue, unframe_steered
60
60
  from dostuff.helpers.agent.side_question import (
61
61
  BTW_FORK_DESCRIPTION, BTW_FORK_PROMPT, add_exchange, answer_side_question, discard_snapshot, kept_prompt,
62
- plan_mode_on, snapshot as live_side_snapshot,
62
+ snapshot as live_side_snapshot,
63
63
  )
64
64
  from dostuff.agent.subagents.fork import ForkContext
65
65
  from dostuff.helpers.agent.quick_memory import append_memory, memory_file, quick_memory_text
66
66
  from dostuff.helpers.agent.context_usage import context_parts, count_tokens, render_context
67
+ from dostuff.helpers.agent.turn_context import is_turn_context, make_context_step
67
68
  from dostuff.helpers.ui.doctor import doctor_checks, hooks_listing
68
69
  from dostuff.helpers.ui.tools_listing import tools_listing
69
70
  from dostuff.helpers.ui.ask_answers import one_line as _one_line_answer, parse_answers
70
71
  from dostuff.helpers.agent.slash_suggestion import slash_arg_hint, slash_suggestion
71
72
  from dostuff.helpers.agent.tool_output import EMPTY_RESPONSE_NUDGE, format_call_label, truncate_tool_output
72
73
  from dostuff.helpers.hooks.dispatch import hook_line
73
- from dostuff.helpers.hooks.events import blocked_prompt_message, parse_stop_note, session_start, user_prompt_submit, with_prompt_context
74
+ from dostuff.helpers.hooks.events import blocked_prompt_message, parse_stop_note, session_start, user_prompt_submit
74
75
  from dostuff.helpers.mcp.load_mcp_config import load_mcp_config, mcp_config_sources, read_mcp_file
75
76
  from dostuff.helpers.skills.custom_commands import discover_commands
76
77
  from dostuff.helpers.skills.skill_command import parse_skill_command, skill_commands, skill_prompt
@@ -287,6 +288,35 @@ class ToolResult(Static):
287
288
  self.set_expanded(not self.expanded)
288
289
 
289
290
 
291
+ class StickyPrompt(Static):
292
+ """The top row of the conversation while its turn's prompt is scrolled out of view: that prompt on one
293
+ row, like a sticky section header. A click goes back to the prompt.
294
+
295
+ On its own layer of `#messages`: in the base layer, appearing would push the conversation down a row
296
+ (the prompt back in view, the bar gone, the prompt out of view again: a flicker at the threshold).
297
+ Inside the scrollable, not over it, so the mouse wheel keeps working with the pointer on the bar."""
298
+
299
+ ALLOW_SELECT = False # a click with a little mouse movement would start a selection instead
300
+
301
+ def __init__(self, **kwargs: Any) -> None:
302
+ super().__init__("", markup=False, **kwargs)
303
+ self.target: Static | None = None
304
+
305
+ def show(self, target: Static | None) -> None:
306
+ if target is self.target:
307
+ return
308
+ self.target = target
309
+ self.display = target is not None
310
+ if target is not None:
311
+ self.update(" ".join(str(target.content).split()))
312
+ self.set_class(target.has_class("msg-shell"), "-shell")
313
+
314
+ def on_click(self) -> None:
315
+ if self.target is None or not isinstance(self.parent, Transcript):
316
+ return
317
+ self.parent.scroll_to(y=self.target.virtual_region.y, animate=False) # also releases the anchor
318
+
319
+
290
320
  class Transcript(VerticalScroll):
291
321
  """The conversation viewport.
292
322
 
@@ -307,6 +337,28 @@ class Transcript(VerticalScroll):
307
337
  self._container_size = region.size
308
338
  return super()._get_scrollable_region(region)
309
339
 
340
+ def on_mount(self) -> None:
341
+ # Pinned to the bottom, the compositor moves scroll_y with set_reactive and its watchers never fire:
342
+ # what moves the view then is the content growing (virtual_size) or the viewport resizing (on_resize).
343
+ self.watch(self, "scroll_y", self._update_sticky_prompt, init=False)
344
+ self.watch(self, "virtual_size", self._update_sticky_prompt, init=False)
345
+
346
+ def on_resize(self) -> None:
347
+ self._update_sticky_prompt()
348
+
349
+ def _update_sticky_prompt(self) -> None:
350
+ self.query_one("#sticky-prompt", StickyPrompt).show(self._prompt_above_view())
351
+
352
+ def _prompt_above_view(self) -> Static | None:
353
+ """The prompt or `!command` whose turn fills the top row, if it is entirely above that row."""
354
+ top = self.scroll_offset.y
355
+ for widget in reversed(self.query_one("#msg-container").children):
356
+ if isinstance(widget, Static) and (widget.has_class("msg-user") or widget.has_class("msg-shell")):
357
+ region = widget.virtual_region
358
+ if region.height and region.y <= top: # no height: mounted, not laid out yet
359
+ return widget if region.bottom <= top else None
360
+ return None
361
+
310
362
 
311
363
  class _JumpToBottomLabel(Static):
312
364
  """The pill inside `JumpToBottom`; a click goes back to the latest message."""
@@ -1663,7 +1715,7 @@ class DostuffTUI(App):
1663
1715
  # grey band (like Claude Code) so turns are easy to find when scrolling.
1664
1716
  CSS = """
1665
1717
  Screen { background: transparent; }
1666
- #messages { height: 1fr; background: transparent; scrollbar-size-vertical: 1; }
1718
+ #messages { height: 1fr; background: transparent; scrollbar-size-vertical: 1; layers: base sticky; }
1667
1719
  #msg-container { height: auto; min-height: 100%; }
1668
1720
  .msg { width: 100%; height: auto; padding: 0 1; margin-top: 1; background: transparent; }
1669
1721
  .msg-user { color: #d0d0d0; background: #373737; }
@@ -1728,6 +1780,12 @@ class DostuffTUI(App):
1728
1780
  text-align: center; color: #8ab4f8; text-style: bold; background: #2c2c2c;
1729
1781
  }
1730
1782
  #jump-bottom-label:hover { background: #3a3a3a; }
1783
+ #sticky-prompt {
1784
+ layer: sticky; dock: top; display: none; width: 100%; height: 1; padding: 0 1;
1785
+ color: #d0d0d0; background: #373737; text-wrap: nowrap; text-overflow: ellipsis;
1786
+ }
1787
+ #sticky-prompt.-shell { color: #d7769f; }
1788
+ #sticky-prompt:hover { background: #4a4a4a; }
1731
1789
  #agent-view { height: 1fr; }
1732
1790
  #agent-view-title { height: auto; padding: 0 1; color: #8ab4f8; text-style: bold; }
1733
1791
  #agent-view-scroll { height: 1fr; border: round #4a4a4a; }
@@ -1867,6 +1925,7 @@ class DostuffTUI(App):
1867
1925
  with Transcript(id="messages", can_focus=False):
1868
1926
  yield Vertical(id="msg-container")
1869
1927
  yield JumpToBottom("↓ Jump to bottom", id="jump-bottom")
1928
+ yield StickyPrompt(id="sticky-prompt")
1870
1929
  yield CommandMenu(id="command-menu")
1871
1930
  yield QueueBar(id="queue-bar")
1872
1931
  btw = BtwPanel(id="btw-panel")
@@ -2229,6 +2288,8 @@ class DostuffTUI(App):
2229
2288
  def _render_history_step(self, step: dict, prefix: str = "") -> None:
2230
2289
  """Render a stored step like the live adapter does (● call / ⎿ result). `prefix` (`[agent: …] `) marks
2231
2290
  a subagent's transcript in /agents."""
2291
+ if is_turn_context(step):
2292
+ return
2232
2293
  role = step.get("role", "?")
2233
2294
  content = step.get("content") or ""
2234
2295
  if role == "tool":
@@ -2982,12 +3043,13 @@ class DostuffTUI(App):
2982
3043
 
2983
3044
  def measure() -> list[tuple[str, int]]:
2984
3045
  return context_parts(
2985
- self._system_instructions + "\n\n" + build_environment_block(),
3046
+ self._system_instructions,
2986
3047
  load_project_instructions(),
2987
3048
  {name: TOOL_SCHEMAS[name] for name in default_tool_names()},
2988
3049
  messages,
2989
3050
  meta.get("compaction_notes") or "",
2990
3051
  lambda text: count_tokens(text, model),
3052
+ next_context=build_environment_block(),
2991
3053
  )
2992
3054
  parts = await asyncio.to_thread(measure)
2993
3055
  text = render_context(parts, get_model_token_limit(), get_model(), meta.get("last_input_tokens") or 0)
@@ -3465,7 +3527,10 @@ class DostuffTUI(App):
3465
3527
  self._start_worker(self._jobs_command(arg), name="jobs")
3466
3528
  return
3467
3529
  if name == "/agents":
3468
- self._start_worker(self._agents_command(arg), name="agents")
3530
+ if arg.strip():
3531
+ self._start_worker(self._agents_command(arg), name="agents")
3532
+ else: # not in a worker: the input is already empty, and a held-back approval would take that gap
3533
+ self._show_agents_list()
3469
3534
  return
3470
3535
  if name == "/queue":
3471
3536
  if arg.lower() == "clear":
@@ -3865,7 +3930,10 @@ class DostuffTUI(App):
3865
3930
  return ForkContext(system_instruction=kept.system_instruction, compaction_notes=notes, history=history,
3866
3931
  tool_names=list(kept.tool_names), session_hook_context=kept.session_hook_context)
3867
3932
  from dostuff.tools.definitions import default_tool_names # pulls in the tools: after the first frame
3868
- return ForkContext(system_instruction=await self._build_instructions(question), compaction_notes=notes,
3933
+ bundle = await self._build_turn_context(question)
3934
+ if bundle: # this snapshot's copy only: a side question stores nothing
3935
+ history.append(make_context_step(bundle))
3936
+ return ForkContext(system_instruction=self._build_instructions(), compaction_notes=notes,
3869
3937
  history=history, tool_names=default_tool_names(),
3870
3938
  session_hook_context=dict(self.session_hook_context))
3871
3939
 
@@ -3880,8 +3948,7 @@ class DostuffTUI(App):
3880
3948
  raise RuntimeError(f"startup failed ({self._backend_error})")
3881
3949
  snap = await self._side_snapshot(question)
3882
3950
  panel.snapshot = snap
3883
- answer = await answer_side_question(snap, list(self._side_exchanges), question,
3884
- plan_mode_on(self.permissions, self.config))
3951
+ answer = await answer_side_question(snap, list(self._side_exchanges), question)
3885
3952
  except asyncio.CancelledError:
3886
3953
  raise # the panel was closed while asking
3887
3954
  except Exception as e:
@@ -4031,8 +4098,12 @@ class DostuffTUI(App):
4031
4098
 
4032
4099
  # ── One agent turn ─────────────────────────────────────────────────────────
4033
4100
 
4034
- async def _build_instructions(self, user_text: str) -> str:
4035
- return await build_turn_instructions(self._system_instructions, user_text, self.memory_store, self.episodic_store, self.user_id)
4101
+ def _build_instructions(self) -> str:
4102
+ return build_system_instructions(self._system_instructions)
4103
+
4104
+ async def _build_turn_context(self, user_text: str, prompt_context: str = "") -> str:
4105
+ return await build_turn_context(user_text, memory_store=self.memory_store, episodic_store=self.episodic_store,
4106
+ user_id=self.user_id, prompt_context=prompt_context)
4036
4107
 
4037
4108
  async def _run_turn(self, user_text: str, wake: bool = False) -> None:
4038
4109
  """One agent turn. `wake`: started by a background job ending (D15) — `user_text` is the pending
@@ -4103,6 +4174,20 @@ class DostuffTUI(App):
4103
4174
  self._append(blocked_prompt_message(blocked), msg_type="system")
4104
4175
  return
4105
4176
 
4177
+ # The turn's context rides ahead of the prompt as a hidden step, never in the system prompt (D5). A
4178
+ # wake turn has no prompt, but the environment moved and the notice text recalls like one
4179
+ bundle = await self._build_turn_context(user_text, prompt_context)
4180
+ if bundle:
4181
+ await append_step(
4182
+ make_context_step(bundle),
4183
+ self.steps_history,
4184
+ working_history,
4185
+ self.current_session_history,
4186
+ self.session_id,
4187
+ self.store,
4188
+ "interactive_loop",
4189
+ )
4190
+ if not wake:
4106
4191
  self._sent_prompts[(self.session_id, len(self.steps_history))] = user_text
4107
4192
  await append_step(
4108
4193
  {"role": "user", "content": content},
@@ -4114,8 +4199,7 @@ class DostuffTUI(App):
4114
4199
  "interactive_loop",
4115
4200
  )
4116
4201
 
4117
- # The hook context is for this turn only: it is not part of the stored user step
4118
- dynamic_instructions = with_prompt_context(await self._build_instructions(user_text), prompt_context)
4202
+ dynamic_instructions = self._build_instructions()
4119
4203
 
4120
4204
  self._set_title("running")
4121
4205
  self._turn_start_time = time.time()
@@ -4667,6 +4751,7 @@ class DostuffTUI(App):
4667
4751
  step = self.steps_history[i]
4668
4752
  content = step.get("content") if isinstance(step, dict) else None
4669
4753
  if (step.get("role") == "user" and isinstance(content, str) and content != EMPTY_RESPONSE_NUDGE
4754
+ and not is_turn_context(step)
4670
4755
  and not content.startswith("[/undo]") and _parse_shell_step(content) is None
4671
4756
  and parse_stop_note(content) is None and parse_notices(content) is None):
4672
4757
  return i
@@ -4696,18 +4781,21 @@ class DostuffTUI(App):
4696
4781
  if self._turn_in_progress or index is None:
4697
4782
  return
4698
4783
  dropped = self.steps_history[index:]
4784
+ # The prompt's context step sits just before it and goes with it; the text below stays on the prompt
4785
+ start = index - 1 if index and is_turn_context(self.steps_history[index - 1]) else index
4786
+ count = len(self.steps_history) - start
4699
4787
  # After a reload _sent_prompts is empty and the stored step may be framed (D6): unframe so
4700
4788
  # Esc-to-restore returns the typed text, never the frame (REQ-2.9).
4701
4789
  text = self._sent_prompts.get((self.session_id, index)) or unframe_steered(
4702
4790
  strip_attachments(dropped[0]["content"]))
4703
4791
  try:
4704
- await self.store.drop_last_steps(self.session_id, len(dropped))
4792
+ await self.store.drop_last_steps(self.session_id, count)
4705
4793
  except Exception as e:
4706
4794
  self._append(f"Could not remove the last prompt: {e}", msg_type="error")
4707
4795
  return
4708
- del self.steps_history[index:]
4796
+ del self.steps_history[start:]
4709
4797
  if self.current_session_history:
4710
- del self.current_session_history[-min(len(dropped), len(self.current_session_history)):]
4798
+ del self.current_session_history[-min(count, len(self.current_session_history)):]
4711
4799
  changed_files = any(
4712
4800
  (tc.get("function") or {}).get("name") in ("write_file", "edit_file", "delete_file")
4713
4801
  for step in dropped for tc in (step.get("tool_calls") or []) if isinstance(tc, dict)