@oh-my-pi/pi-coding-agent 17.2.13 → 17.2.15

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 (239) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/{CHANGELOG-d8xh7keh.md → CHANGELOG-fk29zh06.md} +30 -0
  3. package/dist/cli.js +5114 -5417
  4. package/dist/types/cleanse/agent.d.ts +3 -0
  5. package/dist/types/cleanse/checkers.d.ts +21 -1
  6. package/dist/types/cleanse/index.d.ts +4 -0
  7. package/dist/types/cleanse/parsers.d.ts +3 -1
  8. package/dist/types/cli/args.d.ts +1 -0
  9. package/dist/types/cli/cleanse-picker.d.ts +17 -0
  10. package/dist/types/cli/command-help.d.ts +3 -0
  11. package/dist/types/cli/progress-reporter.d.ts +19 -0
  12. package/dist/types/commands/cleanse.d.ts +11 -0
  13. package/dist/types/commands/compress.d.ts +37 -0
  14. package/dist/types/commands/launch-help.d.ts +3 -0
  15. package/dist/types/commands/launch.d.ts +3 -0
  16. package/dist/types/compress/index.d.ts +27 -0
  17. package/dist/types/compress/protocol.d.ts +49 -0
  18. package/dist/types/compress/session.d.ts +15 -0
  19. package/dist/types/compress/types.d.ts +54 -0
  20. package/dist/types/config/settings-schema.d.ts +10 -0
  21. package/dist/types/internal-urls/local-protocol.d.ts +8 -0
  22. package/dist/types/mcp/transports/header-policy.d.ts +8 -0
  23. package/dist/types/mcp/transports/http.d.ts +2 -0
  24. package/dist/types/mcp/types.d.ts +19 -0
  25. package/dist/types/modes/components/late-diagnostics-message.d.ts +2 -0
  26. package/dist/types/modes/components/todo-reminder.d.ts +2 -0
  27. package/dist/types/modes/components/tool-activity.d.ts +17 -0
  28. package/dist/types/modes/components/transcript-container.d.ts +2 -0
  29. package/dist/types/modes/components/ttsr-notification.d.ts +2 -0
  30. package/dist/types/modes/interactive-mode.d.ts +3 -1
  31. package/dist/types/modes/types.d.ts +3 -1
  32. package/dist/types/modes/utils/transcript-render-helpers.d.ts +2 -1
  33. package/dist/types/modes/utils/ui-helpers.d.ts +3 -1
  34. package/dist/types/session/agent-session-types.d.ts +2 -0
  35. package/dist/types/session/agent-session.d.ts +2 -0
  36. package/dist/types/session/session-tools.d.ts +13 -0
  37. package/dist/types/tools/builtin-names.d.ts +1 -2
  38. package/dist/types/tools/index.d.ts +1 -0
  39. package/dist/types/tools/think.d.ts +41 -0
  40. package/dist/types/utils/zip.d.ts +19 -9
  41. package/package.json +13 -13
  42. package/src/cleanse/agent.ts +67 -2
  43. package/src/cleanse/checkers.ts +252 -21
  44. package/src/cleanse/index.ts +90 -36
  45. package/src/cleanse/parsers.ts +243 -20
  46. package/src/cleanse/prompts/discovery.md +74 -0
  47. package/src/cli/args.ts +3 -0
  48. package/src/cli/cleanse-picker.ts +86 -0
  49. package/src/cli/command-help.ts +4 -0
  50. package/src/cli/flag-tables.ts +1 -0
  51. package/src/cli/gallery-fixtures/agentic.ts +16 -0
  52. package/src/{cleanse/progress.ts → cli/progress-reporter.ts} +12 -7
  53. package/src/cli-commands.ts +5 -0
  54. package/src/commands/cleanse.ts +19 -4
  55. package/src/commands/compress.ts +45 -0
  56. package/src/commands/launch-help.ts +3 -0
  57. package/src/commit/agentic/prompts/analyze-file.md +6 -6
  58. package/src/commit/agentic/prompts/session-user.md +4 -4
  59. package/src/compress/index.ts +318 -0
  60. package/src/compress/prompts/request.md +11 -0
  61. package/src/compress/prompts/review.md +17 -0
  62. package/src/compress/prompts/system.md +81 -0
  63. package/src/compress/protocol.ts +210 -0
  64. package/src/compress/session.ts +72 -0
  65. package/src/compress/types.ts +59 -0
  66. package/src/config/settings-schema.ts +11 -0
  67. package/src/discovery/builtin-rules/go-add-cleanup.md +8 -8
  68. package/src/discovery/builtin-rules/go-exp-promoted.md +8 -8
  69. package/src/discovery/builtin-rules/go-ioutil.md +12 -12
  70. package/src/discovery/builtin-rules/go-new-expr.md +8 -8
  71. package/src/discovery/builtin-rules/go-range-int.md +5 -5
  72. package/src/discovery/builtin-rules/rs-box-leak.md +7 -7
  73. package/src/discovery/builtin-rules/rs-future-prelude.md +4 -4
  74. package/src/discovery/builtin-rules/rs-parking-lot.md +6 -6
  75. package/src/discovery/builtin-rules/ts-no-any.md +5 -5
  76. package/src/discovery/builtin-rules/ts-no-deprecated-leftovers.md +8 -8
  77. package/src/discovery/builtin-rules/ts-no-inline-cast-access.md +13 -14
  78. package/src/discovery/builtin-rules/ts-no-local-is-record.md +7 -7
  79. package/src/discovery/builtin-rules/ts-no-test-timers.md +3 -9
  80. package/src/discovery/builtin-rules/ts-no-tiny-functions.md +7 -7
  81. package/src/discovery/builtin-rules/ts-promise-with-resolvers.md +2 -2
  82. package/src/discovery/builtin-rules/ts-redundant-clear-guard.md +3 -9
  83. package/src/discovery/builtin-rules/ts-set-map.md +2 -4
  84. package/src/internal-urls/local-protocol.ts +42 -0
  85. package/src/live/prompts/live-instructions.md +10 -10
  86. package/src/main.ts +4 -0
  87. package/src/mcp/client.ts +7 -3
  88. package/src/mcp/transports/header-policy.ts +28 -0
  89. package/src/mcp/transports/http.ts +200 -35
  90. package/src/mcp/types.ts +21 -0
  91. package/src/modes/components/chat-transcript-builder.ts +17 -5
  92. package/src/modes/components/late-diagnostics-message.ts +12 -1
  93. package/src/modes/components/todo-reminder.ts +12 -0
  94. package/src/modes/components/tool-activity.ts +45 -0
  95. package/src/modes/components/transcript-container.ts +16 -0
  96. package/src/modes/components/ttsr-notification.ts +12 -0
  97. package/src/modes/controllers/event-controller.ts +3 -6
  98. package/src/modes/controllers/input-controller.ts +6 -6
  99. package/src/modes/controllers/selector-controller.ts +8 -6
  100. package/src/modes/interactive-mode.ts +5 -40
  101. package/src/modes/print-mode.ts +13 -54
  102. package/src/modes/types.ts +1 -1
  103. package/src/modes/utils/transcript-render-helpers.ts +3 -2
  104. package/src/modes/utils/ui-helpers.ts +17 -7
  105. package/src/prompts/advisor/active-repo-watchdog.md +3 -4
  106. package/src/prompts/advisor/advise-tool.md +3 -3
  107. package/src/prompts/advisor/context-files.md +1 -1
  108. package/src/prompts/advisor/system.md +45 -65
  109. package/src/prompts/agents/designer.md +44 -44
  110. package/src/prompts/agents/init.md +18 -18
  111. package/src/prompts/agents/librarian.md +31 -31
  112. package/src/prompts/agents/reviewer.md +34 -39
  113. package/src/prompts/agents/security-reviewer.md +3 -5
  114. package/src/prompts/agents/task.md +11 -12
  115. package/src/prompts/bench.md +2 -5
  116. package/src/prompts/ci-green-request.md +13 -15
  117. package/src/prompts/dry-balance-bench.md +5 -5
  118. package/src/prompts/goals/goal-budget-limit.md +4 -5
  119. package/src/prompts/goals/goal-continuation.md +11 -11
  120. package/src/prompts/goals/goal-mode-active.md +7 -7
  121. package/src/prompts/goals/goal-todo-context.md +2 -2
  122. package/src/prompts/goals/guided-goal-interview.md +18 -24
  123. package/src/prompts/memories/read-path.md +9 -9
  124. package/src/prompts/memories/stage_one_system.md +9 -11
  125. package/src/prompts/review-custom-request.md +8 -11
  126. package/src/prompts/review-headless-request.md +3 -10
  127. package/src/prompts/security/scan-coordinator.md +6 -5
  128. package/src/prompts/security/validate-request.md +4 -7
  129. package/src/prompts/skills/user-invocation.md +2 -2
  130. package/src/prompts/steering/parent-irc.md +1 -1
  131. package/src/prompts/steering/user-interjection.md +1 -3
  132. package/src/prompts/system/active-repo-context.md +4 -2
  133. package/src/prompts/system/agent-creation-architect.md +22 -37
  134. package/src/prompts/system/agent-creation-user.md +3 -3
  135. package/src/prompts/system/auto-continue.md +1 -1
  136. package/src/prompts/system/auto-thinking-difficulty-local.md +5 -7
  137. package/src/prompts/system/auto-thinking-difficulty.md +8 -10
  138. package/src/prompts/system/autolearn-guidance-learn.md +2 -1
  139. package/src/prompts/system/autolearn-guidance.md +5 -4
  140. package/src/prompts/system/autolearn-nudge-autocontinue.md +3 -3
  141. package/src/prompts/system/background-tan-dispatch.md +3 -3
  142. package/src/prompts/system/btw-user.md +2 -2
  143. package/src/prompts/system/commit-message-system.md +8 -6
  144. package/src/prompts/system/eager-task.md +3 -3
  145. package/src/prompts/system/empty-stop-retry.md +1 -1
  146. package/src/prompts/system/gemini-tool-call-reminder.md +5 -5
  147. package/src/prompts/system/interrupted-thinking.md +3 -3
  148. package/src/prompts/system/irc-autoreply.md +1 -1
  149. package/src/prompts/system/irc-incoming.md +3 -3
  150. package/src/prompts/system/manual-continue.md +3 -3
  151. package/src/prompts/system/mcp-xdev-guidance.md +2 -2
  152. package/src/prompts/system/memory-consolidation-system.md +2 -2
  153. package/src/prompts/system/mid-run-todo-nudge.md +1 -1
  154. package/src/prompts/system/orchestrate-notice.md +25 -25
  155. package/src/prompts/system/personalities/default.md +9 -9
  156. package/src/prompts/system/personalities/friendly.md +11 -11
  157. package/src/prompts/system/personalities/pragmatic.md +8 -8
  158. package/src/prompts/system/plan-mode-active.md +61 -64
  159. package/src/prompts/system/plan-mode-approved.md +10 -11
  160. package/src/prompts/system/plan-mode-compact-instructions.md +11 -11
  161. package/src/prompts/system/plan-mode-reference.md +5 -5
  162. package/src/prompts/system/plan-yolo-handoff.md +2 -2
  163. package/src/prompts/system/prewalk-checklist.md +5 -5
  164. package/src/prompts/system/prewalk-continue.md +1 -1
  165. package/src/prompts/system/prewalk-plan.md +8 -9
  166. package/src/prompts/system/project-prompt.md +11 -12
  167. package/src/prompts/system/recap-user.md +1 -1
  168. package/src/prompts/system/resolve-device-reminder.md +1 -1
  169. package/src/prompts/system/rewind-report.md +3 -3
  170. package/src/prompts/system/side-channel-no-tools.md +3 -1
  171. package/src/prompts/system/snapcompact-context-stub.md +1 -1
  172. package/src/prompts/system/snapcompact-system-frames-note.md +1 -1
  173. package/src/prompts/system/snapcompact-system-stub.md +1 -1
  174. package/src/prompts/system/snapcompact-toolresult-note.md +1 -1
  175. package/src/prompts/system/speech-rewrite.md +11 -13
  176. package/src/prompts/system/subagent-async-pending.md +5 -5
  177. package/src/prompts/system/subagent-system-prompt.md +5 -15
  178. package/src/prompts/system/subagent-user-prompt.md +1 -1
  179. package/src/prompts/system/subagent-yield-reminder.md +12 -12
  180. package/src/prompts/system/system-prompt.md +110 -136
  181. package/src/prompts/system/tan-context-switch.md +8 -14
  182. package/src/prompts/system/task-label.md +3 -3
  183. package/src/prompts/system/thinking-loop-redirect.md +6 -6
  184. package/src/prompts/system/title-marker-instruction.md +2 -1
  185. package/src/prompts/system/title-system.md +3 -5
  186. package/src/prompts/system/ttsr-interrupt.md +3 -3
  187. package/src/prompts/system/ttsr-tool-reminder.md +1 -1
  188. package/src/prompts/system/ultrathink-notice.md +1 -1
  189. package/src/prompts/system/unexpected-stop-classifier.md +3 -3
  190. package/src/prompts/system/vibe-mode-active.md +15 -15
  191. package/src/prompts/system/web-search.md +16 -16
  192. package/src/prompts/system/workflow-notice.md +35 -33
  193. package/src/prompts/system/xdev-mount-notice.md +4 -4
  194. package/src/prompts/tools/apply-patch.md +22 -23
  195. package/src/prompts/tools/approve.md +5 -0
  196. package/src/prompts/tools/ask.md +10 -10
  197. package/src/prompts/tools/checkpoint.md +7 -7
  198. package/src/prompts/tools/computer.md +16 -16
  199. package/src/prompts/tools/github.md +12 -12
  200. package/src/prompts/tools/goal.md +8 -9
  201. package/src/prompts/tools/grep.md +5 -5
  202. package/src/prompts/tools/image-attachment-describe-system.md +6 -6
  203. package/src/prompts/tools/image-attachment-describe.md +3 -8
  204. package/src/prompts/tools/image-gen.md +4 -4
  205. package/src/prompts/tools/inspect-image-system.md +10 -10
  206. package/src/prompts/tools/inspect-image.md +10 -13
  207. package/src/prompts/tools/learn.md +4 -4
  208. package/src/prompts/tools/manage-skill.md +9 -6
  209. package/src/prompts/tools/memory-edit.md +8 -8
  210. package/src/prompts/tools/recall.md +4 -4
  211. package/src/prompts/tools/reflect.md +2 -2
  212. package/src/prompts/tools/replace.md +13 -11
  213. package/src/prompts/tools/retain.md +3 -4
  214. package/src/prompts/tools/rewind.md +7 -8
  215. package/src/prompts/tools/rewrite.md +12 -0
  216. package/src/prompts/tools/security-publish.md +5 -1
  217. package/src/prompts/tools/security-scan.md +10 -1
  218. package/src/prompts/tools/task-async-contract.md +7 -1
  219. package/src/prompts/tools/todo.md +27 -25
  220. package/src/prompts/tools/vibe-kill.md +2 -2
  221. package/src/prompts/tools/vibe-list.md +2 -2
  222. package/src/prompts/tools/vibe-send.md +6 -7
  223. package/src/prompts/tools/vibe-spawn.md +8 -6
  224. package/src/prompts/tools/web-search.md +5 -5
  225. package/src/sdk.ts +10 -1
  226. package/src/session/agent-session-types.ts +2 -0
  227. package/src/session/agent-session.ts +28 -0
  228. package/src/session/session-handoff.ts +21 -0
  229. package/src/session/session-tools.ts +47 -0
  230. package/src/tools/builtin-names.ts +1 -2
  231. package/src/tools/index.ts +10 -0
  232. package/src/tools/read-format.ts +8 -3
  233. package/src/tools/read.ts +18 -7
  234. package/src/tools/renderers.ts +2 -0
  235. package/src/tools/think.ts +84 -0
  236. package/src/tools/write.ts +1 -1
  237. package/src/utils/file-mentions.ts +8 -2
  238. package/src/utils/zip.ts +858 -94
  239. package/dist/types/cleanse/progress.d.ts +0 -14
@@ -1,7 +1,7 @@
1
- Generates or edits images.
1
+ Generates/edits images.
2
2
 
3
3
  <instructions>
4
- - Provide a single detailed `subject` prompt for generation or editing.
5
- - When using multiple `input`, describe each image's role in `subject` (e.g. `Image 1` for composition, `Image 2` for lighting).
6
- - For text: add "sharp, legible, correctly spelled"; keep text short.
4
+ - One detailed `subject` prompt: generation or editing.
5
+ - Multiple `input`: describe each image's role in `subject` (e.g. `Image 1` for composition, `Image 2` for lighting).
6
+ - Text: add "sharp, legible, correctly spelled"; keep short.
7
7
  </instructions>
@@ -1,20 +1,20 @@
1
- You are an image-analysis assistant.
1
+ Image-analysis assistant.
2
2
 
3
3
  Core behavior:
4
- - Be evidence-first: distinguish direct observations from inferences.
5
- - If something is unclear, say uncertain rather than guessing.
4
+ - Evidence-first: direct observations and inferences distinct.
5
+ - If unclear, say uncertain—not guess.
6
6
  - NEVER fabricate unreadable or occluded details.
7
- - Keep output compact and useful.
7
+ - Output compact, useful.
8
8
 
9
- Default output format (unless the requested question asks for another format):
9
+ Default format unless question requests another:
10
10
  1) Answer
11
11
  2) Key evidence
12
12
  3) Caveats / uncertainty
13
13
 
14
- For OCR-style requests:
14
+ OCR-style requests:
15
15
  - Preserve exact visible text, including casing and punctuation.
16
- - If text is partially unreadable, mark the unreadable segments explicitly.
16
+ - Partially unreadable text: explicitly mark unreadable segments.
17
17
 
18
- For UI/screenshot debugging requests:
19
- - Focus on visible states, labels, toggles, error messages, disabled controls, and relevant affordances.
20
- - Separate observed UI state from probable root cause.
18
+ UI/screenshot debugging:
19
+ - Focus: visible states, labels, toggles, error messages, disabled controls, relevant affordances.
20
+ - Observed UI state and probable root cause separate.
@@ -1,22 +1,19 @@
1
- Inspects an image file with a vision-capable model and returns compact text analysis.
1
+ Inspects image files via a vision-capable model; returns compact text analysis.
2
2
 
3
3
  <instruction>
4
- - Use this for image understanding tasks (OCR, UI/screenshot debugging, scene/object questions)
5
- - Provide `path` as a local image file path, `Image #N` attachment label, or `attachment://N` URI
6
- - Write a specific `question`:
7
- - what to inspect
8
- - constraints (for example: "quote visible text verbatim", "only report confirmed findings")
9
- - desired output format (bullets/table/JSON/short answer)
10
- - Keep `question` grounded in observable evidence and ask for uncertainty when details are unclear
11
- - Use this tool over `read` when the goal is image analysis
4
+ - Use for image understanding: OCR, UI/screenshot debugging, scene/object questions.
5
+ - `path`: local image-file path | `Image #N` attachment label | `attachment://N` URI.
6
+ - `question` specific: inspection target; constraints (e.g. "quote visible text verbatim", "only report confirmed findings"); output format (bullets/table/JSON/short answer).
7
+ - Ground `question` in observable evidence; request uncertainty for unclear details.
8
+ - For image analysis, use over `read`.
12
9
  </instruction>
13
10
 
14
11
  <output>
15
- - Returns text-only analysis from the vision model
16
- - No image content blocks are returned in tool output
12
+ - Vision-model text-only analysis.
13
+ - Tool output: no image content blocks.
17
14
  </output>
18
15
 
19
16
  <critical>
20
- - If image submission is blocked by settings, the tool will fail with an actionable error
21
- - If configured model does not support image input, configure a vision-capable model role before retrying
17
+ - Settings-blocked image submission actionable error.
18
+ - Configured model lacks image input configure a vision-capable model role before retrying.
22
19
  </critical>
@@ -1,7 +1,7 @@
1
- Capture a reusable lesson into long-term memory, and optionally mint or enhance a managed skill in the same call.
1
+ Capture reusable lessons in long-term memory; optionally mint/enhance a managed skill in the same call.
2
2
 
3
- Use after solving something whose insight will pay off again: a non-obvious fix, a project convention you had to discover, a workflow that worked.
3
+ Use after solving insight likely to pay off again: a non-obvious fix, discovered project convention, or workflow that worked.
4
4
 
5
- Provide the optional `skill` object when the lesson is a repeatable *procedure* worth codifying as a `SKILL.md` (not just a fact). Managed skills are written to an isolated directory (`~/.omp/agent/managed-skills`) and are surfaced like normal skills next session. They NEVER touch user-authored skills. Frontmatter is generated from `name` and `description`.
5
+ `skill` optional; provide only for a repeatable procedure worth codifying as `SKILL.md`, not a fact. Managed skills: isolated `~/.omp/agent/managed-skills`; surfaced as normal skills next session; NEVER touch user-authored skills. Frontmatter: generated from `name` and `description`.
6
6
 
7
- Capture sparingly and specifically. One strong, reusable lesson beats several vague ones.
7
+ Capture sparingly, specifically: one strong reusable lesson > several vague ones.
@@ -1,9 +1,12 @@
1
- Create, update, or delete a managed skill — a `SKILL.md` written to an isolated directory (`~/.omp/agent/managed-skills`) and surfaced like a normal skill in future sessions.
1
+ Managed skill: `SKILL.md` in isolated `~/.omp/agent/managed-skills`; surfaced as a normal skill in future sessions.
2
2
 
3
- Managed skills are for repeatable procedures worth codifying: a setup sequence, a debugging recipe, a project-specific workflow. They are kept separate from user-authored skills and this tool NEVER edits those.
3
+ Use: repeatable procedures worth codifying setup sequence, debugging recipe, project-specific workflow.
4
+ User-authored skills separate; tool NEVER edits them.
4
5
 
5
- - `action: "create"` — fails if the skill already exists.
6
- - `action: "update"` — overwrites the body; fails if the skill does not exist.
7
- - `action: "delete"` — fails if the skill does not exist.
6
+ - `action: "create"` — fails if skill exists.
7
+ - `action: "update"` — overwrites body; fails if skill absent.
8
+ - `action: "delete"` — fails if skill absent.
8
9
 
9
- `name` is kebab-case (lowercase letters, digits, hyphens). The `description` drives discovery, so make it specific. Do not include frontmatter in `body`; it is generated from `name` and `description`.
10
+ `name`: kebab-case (lowercase letters, digits, hyphens).
11
+ `description`: specific; drives discovery.
12
+ No frontmatter in `body`; generated from `name` and `description`.
@@ -1,12 +1,12 @@
1
- Edit Mnemopi long-term memories by id.
1
+ Edit Mnemopi long-term memories by id. Only ids returned by `recall`.
2
2
 
3
- Use only with ids returned by the `recall` tool. Operations:
4
- - `update`: replace content and/or importance for a working memory.
5
- - `forget`: permanently delete a working memory.
6
- - `invalidate`: softly supersede a working or episodic memory, optionally pointing at `replacement_id`.
3
+ Operations:
4
+ - `update`: working memory; replace content and/or importance.
5
+ - `forget`: permanently delete working memory.
6
+ - `invalidate`: softly supersede working or episodic memory; optional `replacement_id`.
7
7
 
8
- Fact ids (recall results marked `[facts]`) are read-only: inspect them with `read memory://<id>`; every edit op on a fact id returns `not_editable`.
8
+ Fact ids — `recall` results marked `[facts]`: read-only. Inspect with `read memory://<id>`; any edit op `not_editable`.
9
9
 
10
- Prefer `invalidate` when a memory became stale but its history may still be useful. Use `forget` only for content that should be hard-deleted.
10
+ Prefer `invalidate` for stale memory whose history may still be useful. Use `forget` only for content requiring hard deletion.
11
11
 
12
- **Always read the full memory before `update`.** Recall results are clipped previews (the trailing `…` marks a truncation and `full_length` reports the original size); `update` replaces content wholesale, so overwriting the preview would delete the unseen tail. Fetch the row first with `read memory://<id>`, then pass the merged content in `content`.
12
+ MUST read full memory before `update`. Recall previews clipped: trailing `…` marks truncation; `full_length` original size. `update` replaces content wholesale updating a preview deletes its unseen tail. First `read memory://<id>`; pass merged content in `content`.
@@ -1,7 +1,7 @@
1
- Search long-term memory for relevant information. Returns raw matching entries ranked by relevance.
1
+ Search long-term memory; return raw relevance-ranked matching entries.
2
2
 
3
- Use proactively before answering questions about past conversations, user preferences, project decisions, or any topic where prior context would help accuracy. When in doubt, recall first.
3
+ Use proactively before questions about past conversations, user preferences, project decisions, or topics where prior context improves accuracy. When in doubt, recall first.
4
4
 
5
- Prefer `recall` when you need specific facts or entries. Use `reflect` instead when you need a synthesized answer across many memories.
5
+ `recall`: specific facts or entries. `reflect`: synthesized answer across many memories.
6
6
 
7
- Content in each result is a preview. A trailing `…` marks a truncation (`truncated: true`, `full_length` gives the original size). Fetch the full row with `read memory://<id>` — required before any `memory_edit update`.
7
+ Results: content preview. Trailing `…`: truncation (`truncated: true`; `full_length`: original size). Before any `memory_edit update`, MUST fetch full row: `read memory://<id>`.
@@ -1,5 +1,5 @@
1
- Generate a synthesized answer by reasoning over long-term memory. Unlike `recall`, `reflect` blends relevant memories into a coherent response.
1
+ `reflect`: synthesizes a coherent response from relevant long-term memories; unlike `recall`, blends them.
2
2
 
3
3
  Use for open-ended questions spanning many stored facts: "What do you know about this user?", "Summarize project decisions.", "What are my preferences for X?"
4
4
 
5
- Optional `context` parameter focuses the synthesis on a specific angle or sub-topic.
5
+ `context` optional; focuses synthesis on a specific angle or sub-topic.
@@ -1,30 +1,32 @@
1
- Performs a single string replacement in a file with fuzzy whitespace matching.
1
+ Single file string replacement; fuzzy whitespace matching.
2
2
 
3
3
  <instruction>
4
- - You MUST use the smallest `old_string` that uniquely identifies the change
5
- - If `old_string` is not unique, you MUST expand it with more context or use `replace_all: true` to replace all occurrences
6
- - Use `replace_all: true` when renaming a string across the file
7
- - You SHOULD prefer editing existing files over creating new ones
4
+ - MUST use smallest `old_string` uniquely identifying change.
5
+ - Nonunique `old_string` MUST add context or use `replace_all: true` for all occurrences.
6
+ - Rename a string across file use `replace_all: true`.
7
+ - SHOULD edit existing files, not create new.
8
8
  </instruction>
9
9
 
10
10
  <output>
11
- Returns success/failure status. On success, file modified in place with replacement applied. On failure (e.g., `old_string` not found or matches multiple locations without `replace_all: true`), returns error describing issue.
11
+ Success/failure status.
12
+ Success: file modified in place; replacement applied.
13
+ Failure — e.g., `old_string` absent or multiple matches without `replace_all: true`: error describes issue.
12
14
  </output>
13
15
 
14
16
  <critical>
15
- - You MUST read the file at least once in the conversation before editing. Tool errors if you attempt edit without reading file first.
17
+ - MUST read file at least once in conversation before editing. Tool errors on edit before read.
16
18
  </critical>
17
19
 
18
20
  <bash-alternatives>
19
- Replace is content-addressed — you identify *what* to change by its text.
21
+ Replace content-addressed — identify change by text.
20
22
 
21
- For pattern-addressed bulk changes, bash is more efficient:
23
+ Pattern-addressed bulk changes: bash more efficient:
22
24
 
23
25
  |Operation|Command|
24
26
  |---|---|
25
27
  |Regex replace|`sd 'pattern' 'replacement' file`|
26
28
  |Bulk replace across files|`sd 'pattern' 'replacement' **/*.ts`|
27
29
 
28
- Use Replace when _content itself_ identifies location; use `ast_edit` for structure-aware codemods.
29
- For in-place edits prefer this tool or `write` — you get a diff preview and fuzzy matching.
30
+ Use Replace when content identifies location; `ast_edit` for structure-aware codemods.
31
+ For in-place edits prefer Replace or `write` — diff preview and fuzzy matching.
30
32
  </bash-alternatives>
@@ -1,6 +1,5 @@
1
- Store one or more facts in long-term memory for future sessions.
1
+ Store ≥1 fact in long-term memory for future sessions.
2
2
 
3
- Use for durable, reusable knowledge: user preferences, project decisions, architectural choices, anything that improves future responses.
4
- Ephemeral task state does not belong here.
3
+ Use: durable, reusable knowledgeuser preferences, project decisions, architectural choices; anything improving future responses. No ephemeral task state.
5
4
 
6
- Each item MUST be specific and self-contained — include who, what, when, and why. Batch related facts in a single call; they are deduplicated and consolidated.
5
+ Each item MUST be specific, self-contained: who, what, when, why. Batch related facts per call; deduplicated and consolidated.
@@ -1,14 +1,13 @@
1
- End an active checkpoint. Rewind context to it, replacing intermediate exploration with your report.
1
+ End active checkpoint; rewind context to it, replacing intermediate exploration with your report.
2
2
 
3
- Call immediately after `checkpoint`-started investigative work.
3
+ Call immediately after investigative work started by `checkpoint`.
4
4
 
5
5
  Requirements:
6
- - `report` MUST be concise, factual, and actionable.
7
- - Include key findings, decisions, and any unresolved risks.
6
+ - `report` MUST be concise, factual, actionable; include key findings, decisions, unresolved risks.
8
7
  - AVOID raw scratch logs unless essential.
9
- - You MUST call this before yielding if a checkpoint is active.
8
+ - MUST call before yielding if checkpoint active.
10
9
 
11
10
  Behavior:
12
- - If no checkpoint is active, this tool errors. If the checkpoint already rewound, continue from the retained report instead of retrying.
13
- - On success, the session rewinds, keeps your report as retained context, and closes the checkpoint.
14
- - A successful rewind is final for that checkpoint; repeat calls error.
11
+ - No active checkpoint error. Checkpoint already rewound continue from retained report; NEVER retry.
12
+ - Success session rewinds, retains your report as context, closes checkpoint.
13
+ - Successful rewind final for that checkpoint; repeat calls error.
@@ -0,0 +1,12 @@
1
+ Submit compressed source draft + every drop.
2
+
3
+ - `text`: complete, verbatim, ready-to-ship compressed output; NEVER diff, summary, or edit description.
4
+ - `losses`: one entry per omitted claim, qualifier, default, bound, example, or exact string; quote/name it and why omission remains correct. Empty array: no losses.
5
+
6
+ Each call: review turn → reply with draft, measured size, declared losses; ask verdict. `rewrite` replaces draft; `approve` accepts.
7
+
8
+ <critical>
9
+ - Declare losses honestly: declared losses auditable; undeclared loss: silent regression.
10
+ - `text` MUST stand alone: reader without source can execute it.
11
+ - New draft supersedes earlier approval.
12
+ </critical>
@@ -1 +1,5 @@
1
- Publish the canonical result of the current OMP-native security scan. Call this exactly once after every in-scope file and candidate has a final disposition. Supply only evidence grounded in repository files inspected during this scan. This tool validates, fingerprints, assigns OMP-owned IDs, writes the canonical security store, and creates SARIF. Do not invent IDs or edit the store directly.
1
+ Publish current OMP-native security scan's canonical result.
2
+ Call exactly once after every in-scope file and candidate reaches final disposition.
3
+ Evidence: only repository files inspected during this scan.
4
+ Tool: validates, fingerprints, assigns OMP-owned IDs, writes canonical security store, creates SARIF.
5
+ NEVER invent IDs or edit store directly.
@@ -1 +1,10 @@
1
- Plan, start, inspect, cancel, and validate OMP-native repository security scans. `preflight` creates an immutable plan pinned to the repository snapshot, model, and exact OAuth credential. `start` runs the plan as a background OMP job. `status` and `cancel` use the returned operation ID. `cloud_scans` lists Codex Security cloud configurations for the exact selected ChatGPT OAuth account. `cloud_start` creates and enables a cloud scan configuration using `repository_id`, `repository_url`, and `environment_id`; this consumes the account's separate Codex Security cloud allowance and is never a fallback from a native scan. `cloud_status` reads cloud progress. `cloud_pull` imports cloud findings into the canonical OMP security store, where they are available through `security://`. Cloud actions use `cloud_configuration_id` and may use `credential_id` to pin an account. Security must be enabled in settings.
1
+ OMP-native repository security scans: plan, start, inspect, cancel, validate.
2
+ `preflight`: immutable plan pinned to repository snapshot, model, exact OAuth credential.
3
+ `start`: plan → background OMP job.
4
+ `status`, `cancel`: returned operation ID.
5
+ `cloud_scans`: Codex Security cloud configurations for exact selected ChatGPT OAuth account.
6
+ `cloud_start`: creates/enables configuration using `repository_id`, `repository_url`, `environment_id`; consumes account's separate Codex Security cloud allowance; NEVER native-scan fallback.
7
+ `cloud_status`: cloud progress.
8
+ `cloud_pull`: cloud findings → canonical OMP security store, available through `security://`.
9
+ Cloud actions: `cloud_configuration_id` required; `credential_id` MAY pin account.
10
+ Security MUST be enabled in settings.
@@ -1 +1,7 @@
1
- No polling is needed. Inspecting a settled job with `hub jobs` or `hub wait` makes that snapshot its delivery, so no duplicate `async-result` follows. Job IDs live in process memory for roughly five minutes after settlement; afterward, use the agent ID with `hub send`, `agent://<id>`, or `history://<id>`. `completed` means the subagent yielded successfully, not that claimed artifacts were verified.
1
+ No polling needed.
2
+
3
+ Settled-job inspection: `hub jobs` | `hub wait` delivers its snapshot → no duplicate `async-result`.
4
+
5
+ Job IDs: process memory ~5min after settlement; afterward use agent ID: `hub send`, `agent://<id>`, `history://<id>`.
6
+
7
+ `completed`: subagent yielded successfully; claimed artifacts unverified.
@@ -1,42 +1,44 @@
1
- **Tasks referenced by verbatim content string, NEVER an auto-generated ID no "task-1"/"task-N" exists. Pass the content text in the `task` field.**
1
+ **Tasks: verbatim content strings, NEVER auto-generated IDs; no "task-1"/"task-N". Pass content in `task`.**
2
2
 
3
- On each completion the earliest still-open task (in phase order) auto-promotes to `in_progress`.
4
- Completing tasks out of phase order can move this pointer **back** to an earlier phase — expected; completed tasks are never reverted.
3
+ Each completion: earliest still-open task (phase order) auto-promotes to `in_progress`. Out-of-order completion may move pointer back to an earlier phase—expected; completed tasks NEVER revert.
5
4
 
6
5
  ## Operations
7
6
 
8
- |`op`|Required fields|Effect|
7
+ |`op`|Fields|Effect|
9
8
  |---|---|---|
10
- |`init`|`list: [{phase, items: string[]}]`|Initialize full list (replaces existing)|
9
+ |`init`|`list: [{phase, items: string[]}]`|Initialize full list; replaces existing|
11
10
  |`init`|`items: string[]`|Flattened single-phase init|
12
11
  |`start`|`task`|Mark in progress|
13
12
  |`done`|`task` or `phase`|Mark completed|
14
13
  |`drop`|`task` or `phase`|Mark abandoned|
15
- |`block`|`task` or `phase`, optional `reason`|Mark **blocked** open but waiting on external input; excluded from the stop-time incomplete-todo reminder|
16
- |`unblock`|`task` or `phase`|Return a blocked task to `pending`|
17
- |`rm`|`task` or `phase` (optional)|Remove task or phase; omit both to clear|
18
- |`append`|`phase`, `items: string[]`|Append tasks to `phase`; lazily creates phase|
19
- |`view`|—|Read-only: echo list|
14
+ |`block`|`task` or `phase`; optional `reason`|Mark blocked: open, awaiting external input; excluded from stop-time incomplete-todo reminder|
15
+ |`unblock`|`task` or `phase`|Blocked task `pending`|
16
+ |`rm`|optional `task` or `phase`|Remove task/phase; omit both clear|
17
+ |`append`|`phase`; `items: string[]`|Append tasks to phase; lazily creates phase|
18
+ |`view`|—|Read-only; echo list|
20
19
 
21
20
  ## Anatomy
22
- - **Task content**: 5–10 words; what, not how. Unique identifier.
23
- - **Phase name**: short noun phrase (e.g. `Foundation`, `Auth`, `Verification`). Unique identifier. NEVER prefix `1.`, `A)`, `Phase 1:`.
21
+
22
+ - Task content: 5–10 words; what, not how; unique identifier.
23
+ - Phase name: short noun phrase (e.g. `Foundation`, `Auth`, `Verification`); unique identifier. NEVER prefix `1.`, `A)`, `Phase 1:`.
24
24
 
25
25
  ## Rules
26
- - Mark tasks done immediately after finishing. Complete phases in order.
27
- - NEVER make a todo call your turn's only tool call — batch it with the real work: `init` with the first reads/edits, each `done`/`start` with the next action. Solo todo turns waste a round trip.
28
- - Waiting on something you can't act on (a user decision, another agent, an external service)? `block` the task (optional `reason`) it stays in the tracker but won't trip the stop reminder; `unblock` when it's actionable again. If the blocker is itself agent-actionable, `append` an unblocking task instead.
29
- - Keep `task`/`phase` strings stable once introduced.
30
- - Lost the exact task text? `view` echoes the list — NEVER guess from memory.
31
-
32
- ## When to create a list
33
- - Task requires 3+ distinct steps
34
- - User explicitly requests one
35
- - User provides a set of tasks
36
- - New instructions arrive mid-task — capture before proceeding
26
+
27
+ - Mark tasks done immediately after finishing; complete phases in order.
28
+ - NEVER make a todo call the turn's only tool call. Batch with real work: `init` with first reads/edits; each `done`/`start` with next action. Solo todo turns waste a round trip.
29
+ - Waiting on something you can't act on—a user decision, another agent, external service: `block` task (optional `reason`); remains tracked but avoids stop reminder. `unblock` when actionable. If blocker agent-actionable, `append` an unblocking task instead.
30
+ - Keep introduced `task`/`phase` strings stable.
31
+ - Lost exact task text: `view` echoes list; NEVER guess from memory.
32
+
33
+ ## Create a list
34
+
35
+ - Task requires 3+ distinct steps.
36
+ - User explicitly requests one.
37
+ - User provides a set of tasks.
38
+ - New instructions arrive mid-task: capture before proceeding.
37
39
 
38
40
  <critical>
39
- User hands you a multi-step plan phased todo, numbered/bulleted checklist, or "N bugs/items/tasks":
40
- - You MUST `init` the list with EVERY item as its own task before working.
41
+ User gives multi-step plan—phased todo, numbered/bulleted checklist, or "N bugs/items/tasks":
42
+ - MUST `init` every item as its own task before working.
41
43
  - Enumerate all; NEVER summarize into fewer tasks, sample "the important ones", drop items, or track the rest from memory.
42
44
  </critical>
@@ -1,3 +1,3 @@
1
- Terminates a worker session: aborts its in-flight turn (if any) and discards the session. Its conversation cannot be continued afterwards — the transcript stays readable at `history://<id>`.
1
+ Terminates worker session: aborts in-flight turn, if any; discards session. Conversation cannot continue; transcript remains readable at `history://<id>`.
2
2
 
3
- Kill sessions that are stuck, looping, or whose workstream is complete. Freeing dead weight keeps the roster legible.
3
+ Kill stuck, looping, or completed-workstream sessions. Free dead weight legible roster.
@@ -1,3 +1,3 @@
1
- Shows your worker-session roster: id, CLI flavor (`fast`/`good`), state (`starting`/`running`/`idle`/`dead`), model, turn count, queued messages, and a one-line gist of each session's latest activity.
1
+ Worker-session roster: id, CLI flavor (`fast`/`good`), state (`starting`/`running`/`idle`/`dead`), model, turn count, queued messages, one-line gist of latest activity.
2
2
 
3
- Use it to reorient: which sessions exist, who is busy, who is idle and ready for the next instruction.
3
+ Use to reorient: existing sessions, busy workers, idle workers ready for next instruction.
@@ -1,9 +1,8 @@
1
- Sends a message to one of your worker sessions (by id from `vibe_spawn` / `vibe_list`). The session keeps its full conversation history refer to earlier work naturally ("now do the same for the other module").
1
+ Send a worker session message by id from `vibe_spawn`/`vibe_list`. Session retains full conversation history; refer naturally ("now do the same for the other module").
2
2
 
3
- Returns immediately with an ack telling you how the message landed:
3
+ Returns immediately with an ack:
4
+ - `turn`: worker idle → new turn; result self-delivers when done.
5
+ - `steered`: worker mid-turn → message injected into the running turn as live steering.
6
+ - `queued`: worker mid-turn and not currently steerable → message runs automatically as next turn.
4
7
 
5
- - `turn` the worker was idle; a new turn started. Its result self-delivers when done.
6
- - `steered` — the worker was mid-turn; your message was injected into the running turn as live steering.
7
- - `queued` — the worker was mid-turn and not steerable right now; your message runs as the next turn automatically.
8
-
9
- Use it for follow-ups, corrections, scope changes, and review requests. Never re-explain prior context — the session already has it.
8
+ Use for follow-ups, corrections, scope changes, review requests. NEVER re-explain prior context; session already has it.
@@ -1,10 +1,12 @@
1
- Starts a persistent worker session — a full coding agent (edit, bash, grep, everything) that you drive by conversation. Pick the CLI flavor per task:
1
+ Starts persistent conversational coding-agent worker session (edit, bash, grep, everything).
2
2
 
3
- - `fast`: low-latency model for mechanical, well-specified work (renames, boilerplate, running tests, data collection).
4
- - `good`: strong model for hard work (design, debugging, multi-file changes, judgment calls).
3
+ CLI flavor by task:
4
+ - `fast`: low-latency model; mechanical, well-specified work (renames, boilerplate, running tests, data collection).
5
+ - `good`: strong model; hard work (design, debugging, multi-file changes, judgment calls).
5
6
 
6
- `prompt` is the session's first instruction. The worker starts with NO context beyond it include files, constraints, and acceptance criteria. `name` (optional) labels the session; otherwise one is generated.
7
+ `prompt`: first session instruction. Worker starts with NO context beyond it; include files, constraints, acceptance criteria.
8
+ `name`: optional session label; otherwise generated.
7
9
 
8
- Returns immediately with the session id; the turn's result (activity trace + the worker's response) is delivered to you automatically when the worker finishes. Do not wait unless you are blocked keep directing other sessions.
10
+ Returns session id immediately. On worker completion, turn resultactivity trace + worker responsedelivered automatically. Do not wait unless blocked; direct other sessions.
9
11
 
10
- The session persists after the turn: it remembers the whole conversation. Continue it with `vibe_send`; never spawn a second session for a follow-up on the same workstream.
12
+ Session persists after turn; remembers whole conversation. Same-workstream follow-up: `vibe_send`; NEVER spawn second session.
@@ -1,8 +1,8 @@
1
- Searches the web for up-to-date information beyond knowledge cutoff.
1
+ Web search: current information beyond knowledge cutoff.
2
2
 
3
3
  <instruction>
4
- - You SHOULD prefer primary sources (papers, official docs) and corroborate key claims with multiple sources
5
- - You MUST include links for cited sources in the final response
6
- - NEVER use for content that is programmatically accessible or whose URL you already know (GitHub repos/issues, a known arXiv paper, a Wikipedia page, official docs) — `read` the URL directly instead
7
- - `query` supports Google-style directives on every provider: `site:`/`-site:`, `after:`/`before:` (`YYYY-MM-DD`), `inurl:`, `intitle:`, `filetype:`, `"exact phrase"`, `-term`, `OR`. Constraints map to native provider filters where available; otherwise results are filtered leniently a constraint matching nothing is relaxed and reported instead of returning zero results.
4
+ - SHOULD prefer primary sources (papers, official docs); corroborate key claims with multiple sources.
5
+ - MUST link cited sources in final response.
6
+ - NEVER use for programmatically accessible content or known URLs (GitHub repos/issues, known arXiv papers, Wikipedia pages, official docs) — `read` URL directly.
7
+ - `query`: every provider supports Google-style `site:`/`-site:`, `after:`/`before:` (`YYYY-MM-DD`), `inurl:`, `intitle:`, `filetype:`, `"exact phrase"`, `-term`, `OR`. Map constraints to native filters when available; otherwise filter results leniently. If a constraint matches nothing, relax and report it; do not return zero results.
8
8
  </instruction>
package/src/sdk.ts CHANGED
@@ -201,6 +201,7 @@ import {
201
201
  ReadTool,
202
202
  releaseComputerSessionsForOwner,
203
203
  resolveMountedXdevExecutable,
204
+ supportsExternalThinking,
204
205
  type Tool,
205
206
  type ToolSession,
206
207
  WebSearchTool,
@@ -3237,7 +3238,14 @@ async function createAgentSessionScoped(options: CreateAgentSessionOptions): Pro
3237
3238
  });
3238
3239
  }
3239
3240
  }
3240
- return settingsAwareStreamFn(streamModel, context, streamOptions);
3241
+ const externalThinking =
3242
+ settings.get("externalThinking") &&
3243
+ agent.state.tools.some(tool => tool.name === "think") &&
3244
+ supportsExternalThinking(streamModel);
3245
+ return settingsAwareStreamFn(streamModel, context, {
3246
+ ...streamOptions,
3247
+ forceReasoningOff: externalThinking || streamOptions?.forceReasoningOff,
3248
+ });
3241
3249
  },
3242
3250
  cursorExecHandlers,
3243
3251
  getCursorTools: () => (toolSession.xdev ? listXdevTools(toolSession.xdev) : []),
@@ -3393,6 +3401,7 @@ async function createAgentSessionScoped(options: CreateAgentSessionOptions): Pro
3393
3401
  createComputerTool: restrictToolNames
3394
3402
  ? undefined
3395
3403
  : async () => (await BUILTIN_TOOLS.computer(toolSession)) ?? null,
3404
+ createThinkTool: async () => (await HIDDEN_TOOLS.think(toolSession)) ?? null,
3396
3405
  createInspectImageTool: restrictToolNames
3397
3406
  ? undefined
3398
3407
  : async () => (await BUILTIN_TOOLS.inspect_image(toolSession)) ?? null,
@@ -164,6 +164,8 @@ export interface AgentSessionConfig {
164
164
  createMemoryTools?: () => Promise<AgentTool[]>;
165
165
  /** Creates the built-in `computer` tool for session-scoped runtime enablement (see {@link AgentSession.setComputerToolEnabled}). */
166
166
  createComputerTool?: () => Promise<AgentTool | null>;
167
+ /** Creates the private `think` scratchpad tool for runtime setting changes. */
168
+ createThinkTool?: () => Promise<AgentTool | null>;
167
169
  /** Creates the built-in `inspect_image` tool for session-scoped runtime enablement (see {@link AgentSession.setInspectImageMode}). */
168
170
  createInspectImageTool?: () => Promise<AgentTool | null>;
169
171
  /** Model registry for API key resolution and model discovery. */
@@ -199,6 +199,7 @@ import {
199
199
  PROPOSE_DEVICE_NAME,
200
200
  writeDeviceDispatch,
201
201
  } from "../tools/resolve";
202
+ import { supportsExternalThinking } from "../tools/think";
202
203
  import type { TodoPhase } from "../tools/todo";
203
204
  import { ToolError } from "../tools/tool-errors";
204
205
  import { parseCommandArgs } from "../utils/command-args";
@@ -1241,6 +1242,7 @@ export class AgentSession {
1241
1242
  toolRegistry: config.toolRegistry,
1242
1243
  createVibeTools: config.createVibeTools,
1243
1244
  createComputerTool: config.createComputerTool,
1245
+ createThinkTool: config.createThinkTool,
1244
1246
  createInspectImageTool: config.createInspectImageTool,
1245
1247
  builtInToolNames: config.builtInToolNames,
1246
1248
  mcpManagerToolNames: config.mcpManagerToolNames,
@@ -4419,6 +4421,11 @@ export class AgentSession {
4419
4421
  return this.#tools.setComputerToolEnabled(enabled);
4420
4422
  }
4421
4423
 
4424
+ /** Applies the external-thinking setting to the private scratchpad tool immediately. */
4425
+ setThinkToolEnabled(enabled: boolean): Promise<boolean> {
4426
+ return this.#tools.setThinkToolEnabled(enabled);
4427
+ }
4428
+
4422
4429
  /**
4423
4430
  * Session-scoped inspect_image mode (`/vision`). `auto` clears the override
4424
4431
  * and returns to the persisted `inspect_image.mode` setting; `on`/`off`
@@ -5176,6 +5183,15 @@ export class AgentSession {
5176
5183
 
5177
5184
  // Skip eager preludes when the user has already queued a directive
5178
5185
  const hasPendingUserDirective = this.#toolChoiceQueue.inspect().includes("user-force");
5186
+ const activeModel = this.agent.state.model;
5187
+ const externalThinkingToolChoice =
5188
+ !options?.synthetic &&
5189
+ !hasPendingUserDirective &&
5190
+ this.settings.get("externalThinking") &&
5191
+ this.getEnabledToolNames().includes("think") &&
5192
+ supportsExternalThinking(activeModel)
5193
+ ? buildNamedToolChoice("think", activeModel)
5194
+ : undefined;
5179
5195
  const eagerTodoPrelude =
5180
5196
  !options?.synthetic && !hasPendingUserDirective ? this.#todo.createEagerTodoPrelude(expandedText) : undefined;
5181
5197
  const eagerTaskPrelude =
@@ -5193,6 +5209,12 @@ export class AgentSession {
5193
5209
  : undefined;
5194
5210
 
5195
5211
  const promptAttribution = options?.attribution ?? (options?.synthetic ? "agent" : "user");
5212
+ if (externalThinkingToolChoice) {
5213
+ this.#toolChoiceQueue.pushOnce(externalThinkingToolChoice, {
5214
+ label: "external-thinking",
5215
+ now: true,
5216
+ });
5217
+ }
5196
5218
  const message = options?.synthetic
5197
5219
  ? { role: "developer" as const, content: userContent, attribution: promptAttribution, timestamp: Date.now() }
5198
5220
  : { role: "user" as const, content: userContent, attribution: promptAttribution, timestamp: Date.now() };
@@ -5223,6 +5245,7 @@ export class AgentSession {
5223
5245
  // Clean up residual eager-todo directive if the prompt never consumed it
5224
5246
  // (e.g., compaction aborted, validation failed).
5225
5247
  this.#toolChoiceQueue.removeByLabel("eager-todo");
5248
+ this.#toolChoiceQueue.removeByLabel("external-thinking");
5226
5249
  }
5227
5250
  return true;
5228
5251
  }
@@ -7043,6 +7066,11 @@ export class AgentSession {
7043
7066
  } catch (error) {
7044
7067
  logger.warn("inspect_image reconcile after model change failed", { error: String(error) });
7045
7068
  }
7069
+ try {
7070
+ await this.#tools.reconcileThinkTool();
7071
+ } catch (error) {
7072
+ logger.warn("think tool reconcile after model change failed", { error: String(error) });
7073
+ }
7046
7074
  }
7047
7075
 
7048
7076
  #closeCodexProviderSessionsForHistoryRewrite(): void {
@@ -14,6 +14,7 @@ import { logger, Snowflake } from "@oh-my-pi/pi-utils";
14
14
  import type { ModelRegistry } from "../config/model-registry";
15
15
  import type { Settings } from "../config/settings";
16
16
  import type { ExtensionRunner, SessionBeforeSwitchResult } from "../extensibility/extensions";
17
+ import { copyLocalArtifacts, resolveLocalUrlToPath } from "../internal-urls";
17
18
  import { obfuscateProviderContext } from "../secrets/message-transform";
18
19
  import type { SecretObfuscator } from "../secrets/obfuscator";
19
20
  import type { HandoffResult, SessionHandoffOptions } from "./agent-session-types";
@@ -255,6 +256,15 @@ export class SessionHandoff {
255
256
  // Stop and settle in-flight advisors while the old-session feeds can still
256
257
  // observe message_end, then mute before opening the replacement session.
257
258
  await this.#host.drainAndDetachAdvisorRecorders();
259
+ // Snapshot the outgoing session's local:// root BEFORE newSession() mints a
260
+ // fresh session id (and therefore a fresh, empty local root). The handoff
261
+ // document routinely references plans/scratch files under local://, so those
262
+ // artifacts must follow the session switch or every reference dangles.
263
+ const localProtocolOptions = {
264
+ getArtifactsDir: () => this.#host.sessionManager.getArtifactsDir(),
265
+ getSessionId: () => this.#host.sessionManager.getSessionId(),
266
+ };
267
+ const previousLocalRoot = resolveLocalUrlToPath("local://", localProtocolOptions);
258
268
  const bashTransition = this.#host.beginBashSessionTransition();
259
269
  this.#host.cancelOwnAsyncJobs();
260
270
  try {
@@ -292,6 +302,17 @@ export class SessionHandoff {
292
302
  this.#host.clearPendingNextTurnMessages();
293
303
  this.#host.resetTodoCycle();
294
304
 
305
+ // Carry local:// artifacts into the replacement session (best-effort: the
306
+ // switch is already committed, so a copy failure must not fail the handoff).
307
+ try {
308
+ const newLocalRoot = resolveLocalUrlToPath("local://", localProtocolOptions);
309
+ await copyLocalArtifacts(previousLocalRoot, newLocalRoot);
310
+ } catch (error) {
311
+ logger.warn("Failed to copy local artifacts into handoff session", {
312
+ error: error instanceof Error ? error.message : String(error),
313
+ });
314
+ }
315
+
295
316
  // Inject the handoff document as a custom message
296
317
  const handoffContent = createHandoffContext(handoffText);
297
318
  this.#host.sessionManager.appendCustomMessageEntry("handoff", handoffContent, true, undefined, "agent");