longer-agent 0.1.0

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 (289) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +227 -0
  3. package/README.zh-CN.md +227 -0
  4. package/agent_templates/executor/agent.yaml +22 -0
  5. package/agent_templates/executor/system_prompt.md +17 -0
  6. package/agent_templates/explorer/agent.yaml +13 -0
  7. package/agent_templates/explorer/system_prompt.md +19 -0
  8. package/agent_templates/main/agent.yaml +7 -0
  9. package/agent_templates/main/system_prompt.md +45 -0
  10. package/configExample.yaml +83 -0
  11. package/dist/agents/agent.d.ts +79 -0
  12. package/dist/agents/agent.d.ts.map +1 -0
  13. package/dist/agents/agent.js +156 -0
  14. package/dist/agents/agent.js.map +1 -0
  15. package/dist/agents/tool-loop.d.ts +140 -0
  16. package/dist/agents/tool-loop.d.ts.map +1 -0
  17. package/dist/agents/tool-loop.js +465 -0
  18. package/dist/agents/tool-loop.js.map +1 -0
  19. package/dist/ask.d.ts +81 -0
  20. package/dist/ask.d.ts.map +1 -0
  21. package/dist/ask.js +34 -0
  22. package/dist/ask.js.map +1 -0
  23. package/dist/auth/openai-oauth.d.ts +66 -0
  24. package/dist/auth/openai-oauth.d.ts.map +1 -0
  25. package/dist/auth/openai-oauth.js +640 -0
  26. package/dist/auth/openai-oauth.js.map +1 -0
  27. package/dist/cli.d.ts +14 -0
  28. package/dist/cli.d.ts.map +1 -0
  29. package/dist/cli.js +254 -0
  30. package/dist/cli.js.map +1 -0
  31. package/dist/commands.d.ts +118 -0
  32. package/dist/commands.d.ts.map +1 -0
  33. package/dist/commands.js +862 -0
  34. package/dist/commands.js.map +1 -0
  35. package/dist/config.d.ts +130 -0
  36. package/dist/config.d.ts.map +1 -0
  37. package/dist/config.js +648 -0
  38. package/dist/config.js.map +1 -0
  39. package/dist/context-rendering.d.ts +69 -0
  40. package/dist/context-rendering.d.ts.map +1 -0
  41. package/dist/context-rendering.js +250 -0
  42. package/dist/context-rendering.js.map +1 -0
  43. package/dist/document-projection.d.ts +12 -0
  44. package/dist/document-projection.d.ts.map +1 -0
  45. package/dist/document-projection.js +75 -0
  46. package/dist/document-projection.js.map +1 -0
  47. package/dist/ephemeral-log.d.ts +15 -0
  48. package/dist/ephemeral-log.d.ts.map +1 -0
  49. package/dist/ephemeral-log.js +173 -0
  50. package/dist/ephemeral-log.js.map +1 -0
  51. package/dist/file-attach.d.ts +89 -0
  52. package/dist/file-attach.d.ts.map +1 -0
  53. package/dist/file-attach.js +571 -0
  54. package/dist/file-attach.js.map +1 -0
  55. package/dist/index.d.ts +29 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +43 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/init-wizard.d.ts +13 -0
  60. package/dist/init-wizard.d.ts.map +1 -0
  61. package/dist/init-wizard.js +328 -0
  62. package/dist/init-wizard.js.map +1 -0
  63. package/dist/log-entry.d.ts +104 -0
  64. package/dist/log-entry.d.ts.map +1 -0
  65. package/dist/log-entry.js +292 -0
  66. package/dist/log-entry.js.map +1 -0
  67. package/dist/log-projection.d.ts +73 -0
  68. package/dist/log-projection.d.ts.map +1 -0
  69. package/dist/log-projection.js +651 -0
  70. package/dist/log-projection.js.map +1 -0
  71. package/dist/mcp-client.d.ts +55 -0
  72. package/dist/mcp-client.d.ts.map +1 -0
  73. package/dist/mcp-client.js +402 -0
  74. package/dist/mcp-client.js.map +1 -0
  75. package/dist/model-selection.d.ts +16 -0
  76. package/dist/model-selection.d.ts.map +1 -0
  77. package/dist/model-selection.js +181 -0
  78. package/dist/model-selection.js.map +1 -0
  79. package/dist/network-retry.d.ts +38 -0
  80. package/dist/network-retry.d.ts.map +1 -0
  81. package/dist/network-retry.js +140 -0
  82. package/dist/network-retry.js.map +1 -0
  83. package/dist/persistence.d.ts +104 -0
  84. package/dist/persistence.d.ts.map +1 -0
  85. package/dist/persistence.js +644 -0
  86. package/dist/persistence.js.map +1 -0
  87. package/dist/primitives/context.d.ts +29 -0
  88. package/dist/primitives/context.d.ts.map +1 -0
  89. package/dist/primitives/context.js +85 -0
  90. package/dist/primitives/context.js.map +1 -0
  91. package/dist/progress.d.ts +51 -0
  92. package/dist/progress.d.ts.map +1 -0
  93. package/dist/progress.js +229 -0
  94. package/dist/progress.js.map +1 -0
  95. package/dist/provider-presets.d.ts +34 -0
  96. package/dist/provider-presets.d.ts.map +1 -0
  97. package/dist/provider-presets.js +181 -0
  98. package/dist/provider-presets.js.map +1 -0
  99. package/dist/providers/anthropic.d.ts +32 -0
  100. package/dist/providers/anthropic.d.ts.map +1 -0
  101. package/dist/providers/anthropic.js +450 -0
  102. package/dist/providers/anthropic.js.map +1 -0
  103. package/dist/providers/base.d.ts +135 -0
  104. package/dist/providers/base.d.ts.map +1 -0
  105. package/dist/providers/base.js +104 -0
  106. package/dist/providers/base.js.map +1 -0
  107. package/dist/providers/glm.d.ts +18 -0
  108. package/dist/providers/glm.d.ts.map +1 -0
  109. package/dist/providers/glm.js +59 -0
  110. package/dist/providers/glm.js.map +1 -0
  111. package/dist/providers/kimi.d.ts +23 -0
  112. package/dist/providers/kimi.d.ts.map +1 -0
  113. package/dist/providers/kimi.js +89 -0
  114. package/dist/providers/kimi.js.map +1 -0
  115. package/dist/providers/minimax.d.ts +20 -0
  116. package/dist/providers/minimax.d.ts.map +1 -0
  117. package/dist/providers/minimax.js +192 -0
  118. package/dist/providers/minimax.js.map +1 -0
  119. package/dist/providers/openai-chat.d.ts +33 -0
  120. package/dist/providers/openai-chat.d.ts.map +1 -0
  121. package/dist/providers/openai-chat.js +543 -0
  122. package/dist/providers/openai-chat.js.map +1 -0
  123. package/dist/providers/openai-responses.d.ts +26 -0
  124. package/dist/providers/openai-responses.d.ts.map +1 -0
  125. package/dist/providers/openai-responses.js +443 -0
  126. package/dist/providers/openai-responses.js.map +1 -0
  127. package/dist/providers/openrouter.d.ts +24 -0
  128. package/dist/providers/openrouter.d.ts.map +1 -0
  129. package/dist/providers/openrouter.js +177 -0
  130. package/dist/providers/openrouter.js.map +1 -0
  131. package/dist/providers/registry.d.ts +7 -0
  132. package/dist/providers/registry.d.ts.map +1 -0
  133. package/dist/providers/registry.js +38 -0
  134. package/dist/providers/registry.js.map +1 -0
  135. package/dist/security/path.d.ts +51 -0
  136. package/dist/security/path.d.ts.map +1 -0
  137. package/dist/security/path.js +187 -0
  138. package/dist/security/path.js.map +1 -0
  139. package/dist/security/sensitive-files.d.ts +3 -0
  140. package/dist/security/sensitive-files.d.ts.map +1 -0
  141. package/dist/security/sensitive-files.js +41 -0
  142. package/dist/security/sensitive-files.js.map +1 -0
  143. package/dist/session.d.ts +446 -0
  144. package/dist/session.d.ts.map +1 -0
  145. package/dist/session.js +4595 -0
  146. package/dist/session.js.map +1 -0
  147. package/dist/settings.d.ts +46 -0
  148. package/dist/settings.d.ts.map +1 -0
  149. package/dist/settings.js +134 -0
  150. package/dist/settings.js.map +1 -0
  151. package/dist/show-context.d.ts +35 -0
  152. package/dist/show-context.d.ts.map +1 -0
  153. package/dist/show-context.js +320 -0
  154. package/dist/show-context.js.map +1 -0
  155. package/dist/skills/loader.d.ts +49 -0
  156. package/dist/skills/loader.d.ts.map +1 -0
  157. package/dist/skills/loader.js +166 -0
  158. package/dist/skills/loader.js.map +1 -0
  159. package/dist/summarize-context.d.ts +29 -0
  160. package/dist/summarize-context.d.ts.map +1 -0
  161. package/dist/summarize-context.js +247 -0
  162. package/dist/summarize-context.js.map +1 -0
  163. package/dist/templates/loader.d.ts +104 -0
  164. package/dist/templates/loader.d.ts.map +1 -0
  165. package/dist/templates/loader.js +514 -0
  166. package/dist/templates/loader.js.map +1 -0
  167. package/dist/tools/basic.d.ts +29 -0
  168. package/dist/tools/basic.d.ts.map +1 -0
  169. package/dist/tools/basic.js +2079 -0
  170. package/dist/tools/basic.js.map +1 -0
  171. package/dist/tools/comm.d.ts +17 -0
  172. package/dist/tools/comm.d.ts.map +1 -0
  173. package/dist/tools/comm.js +192 -0
  174. package/dist/tools/comm.js.map +1 -0
  175. package/dist/tools/web-fetch.d.ts +11 -0
  176. package/dist/tools/web-fetch.d.ts.map +1 -0
  177. package/dist/tools/web-fetch.js +237 -0
  178. package/dist/tools/web-fetch.js.map +1 -0
  179. package/dist/tools/web-search.d.ts +24 -0
  180. package/dist/tools/web-search.d.ts.map +1 -0
  181. package/dist/tools/web-search.js +51 -0
  182. package/dist/tools/web-search.js.map +1 -0
  183. package/dist/tui/app.d.ts +35 -0
  184. package/dist/tui/app.d.ts.map +1 -0
  185. package/dist/tui/app.js +1042 -0
  186. package/dist/tui/app.js.map +1 -0
  187. package/dist/tui/checkbox-picker.d.ts +35 -0
  188. package/dist/tui/checkbox-picker.d.ts.map +1 -0
  189. package/dist/tui/checkbox-picker.js +85 -0
  190. package/dist/tui/checkbox-picker.js.map +1 -0
  191. package/dist/tui/command-picker.d.ts +31 -0
  192. package/dist/tui/command-picker.d.ts.map +1 -0
  193. package/dist/tui/command-picker.js +113 -0
  194. package/dist/tui/command-picker.js.map +1 -0
  195. package/dist/tui/components/ask-panel.d.ts +21 -0
  196. package/dist/tui/components/ask-panel.d.ts.map +1 -0
  197. package/dist/tui/components/ask-panel.js +81 -0
  198. package/dist/tui/components/ask-panel.js.map +1 -0
  199. package/dist/tui/components/conversation-panel.d.ts +68 -0
  200. package/dist/tui/components/conversation-panel.d.ts.map +1 -0
  201. package/dist/tui/components/conversation-panel.js +611 -0
  202. package/dist/tui/components/conversation-panel.js.map +1 -0
  203. package/dist/tui/components/input-panel.d.ts +27 -0
  204. package/dist/tui/components/input-panel.d.ts.map +1 -0
  205. package/dist/tui/components/input-panel.js +725 -0
  206. package/dist/tui/components/input-panel.js.map +1 -0
  207. package/dist/tui/components/logo-panel.d.ts +14 -0
  208. package/dist/tui/components/logo-panel.d.ts.map +1 -0
  209. package/dist/tui/components/logo-panel.js +37 -0
  210. package/dist/tui/components/logo-panel.js.map +1 -0
  211. package/dist/tui/components/plan-panel.d.ts +10 -0
  212. package/dist/tui/components/plan-panel.d.ts.map +1 -0
  213. package/dist/tui/components/plan-panel.js +8 -0
  214. package/dist/tui/components/plan-panel.js.map +1 -0
  215. package/dist/tui/components/status-bar.d.ts +24 -0
  216. package/dist/tui/components/status-bar.d.ts.map +1 -0
  217. package/dist/tui/components/status-bar.js +80 -0
  218. package/dist/tui/components/status-bar.js.map +1 -0
  219. package/dist/tui/input/editor-state.d.ts +22 -0
  220. package/dist/tui/input/editor-state.d.ts.map +1 -0
  221. package/dist/tui/input/editor-state.js +157 -0
  222. package/dist/tui/input/editor-state.js.map +1 -0
  223. package/dist/tui/input/keymap.d.ts +3 -0
  224. package/dist/tui/input/keymap.d.ts.map +1 -0
  225. package/dist/tui/input/keymap.js +72 -0
  226. package/dist/tui/input/keymap.js.map +1 -0
  227. package/dist/tui/input/paste-slots.d.ts +17 -0
  228. package/dist/tui/input/paste-slots.d.ts.map +1 -0
  229. package/dist/tui/input/paste-slots.js +46 -0
  230. package/dist/tui/input/paste-slots.js.map +1 -0
  231. package/dist/tui/input/paste.d.ts +15 -0
  232. package/dist/tui/input/paste.d.ts.map +1 -0
  233. package/dist/tui/input/paste.js +35 -0
  234. package/dist/tui/input/paste.js.map +1 -0
  235. package/dist/tui/input/protocol.d.ts +9 -0
  236. package/dist/tui/input/protocol.d.ts.map +1 -0
  237. package/dist/tui/input/protocol.js +387 -0
  238. package/dist/tui/input/protocol.js.map +1 -0
  239. package/dist/tui/input/sanitize.d.ts +6 -0
  240. package/dist/tui/input/sanitize.d.ts.map +1 -0
  241. package/dist/tui/input/sanitize.js +20 -0
  242. package/dist/tui/input/sanitize.js.map +1 -0
  243. package/dist/tui/input/types.d.ts +18 -0
  244. package/dist/tui/input/types.d.ts.map +1 -0
  245. package/dist/tui/input/types.js +2 -0
  246. package/dist/tui/input/types.js.map +1 -0
  247. package/dist/tui/launch.d.ts +23 -0
  248. package/dist/tui/launch.d.ts.map +1 -0
  249. package/dist/tui/launch.js +104 -0
  250. package/dist/tui/launch.js.map +1 -0
  251. package/dist/tui/theme.d.ts +20 -0
  252. package/dist/tui/theme.d.ts.map +1 -0
  253. package/dist/tui/theme.js +29 -0
  254. package/dist/tui/theme.js.map +1 -0
  255. package/dist/tui/types.d.ts +136 -0
  256. package/dist/tui/types.d.ts.map +1 -0
  257. package/dist/tui/types.js +9 -0
  258. package/dist/tui/types.js.map +1 -0
  259. package/package.json +76 -0
  260. package/prompts/sections/agents_md.md +23 -0
  261. package/prompts/sections/important_log.md +16 -0
  262. package/prompts/sections/system_mechanisms.md +18 -0
  263. package/prompts/tools/apply_patch.md +31 -0
  264. package/prompts/tools/ask.md +18 -0
  265. package/prompts/tools/bash.md +13 -0
  266. package/prompts/tools/bash_background.md +9 -0
  267. package/prompts/tools/bash_output.md +9 -0
  268. package/prompts/tools/check_status.md +3 -0
  269. package/prompts/tools/diff.md +5 -0
  270. package/prompts/tools/edit_file.md +11 -0
  271. package/prompts/tools/glob.md +7 -0
  272. package/prompts/tools/grep.md +20 -0
  273. package/prompts/tools/kill_agent.md +3 -0
  274. package/prompts/tools/kill_shell.md +5 -0
  275. package/prompts/tools/list_dir.md +5 -0
  276. package/prompts/tools/plan.md +252 -0
  277. package/prompts/tools/read_file.md +9 -0
  278. package/prompts/tools/show_context.md +12 -0
  279. package/prompts/tools/skill.md +7 -0
  280. package/prompts/tools/spawn_agent.md +195 -0
  281. package/prompts/tools/summarize_context.md +122 -0
  282. package/prompts/tools/test.md +5 -0
  283. package/prompts/tools/wait.md +17 -0
  284. package/prompts/tools/web_fetch.md +9 -0
  285. package/prompts/tools/web_search.md +5 -0
  286. package/prompts/tools/write_file.md +11 -0
  287. package/skills/.staging/.gitkeep +0 -0
  288. package/skills/explain-code/SKILL.md +15 -0
  289. package/skills/skill-manager/SKILL.md +83 -0
@@ -0,0 +1,252 @@
1
+ ## `plan`
2
+
3
+ Use a tracked plan for non-trivial work.
4
+
5
+ A plan is a live execution guide. You do not need to fully design the whole task up front. Instead, first identify the overall route, then refine and execute one checkpoint at a time.
6
+
7
+ ### When to use a plan
8
+
9
+ Use `plan` when the task is more than a quick obvious change.
10
+
11
+ Typical cases:
12
+
13
+ - The task spans multiple files, modules, or phases
14
+ - The implementation path is not fully obvious yet
15
+ - You should first find existing patterns or reusable code
16
+ - The work benefits from staged validation
17
+ - The task may benefit from `explorer` sub-agents
18
+ - The task has roughly 3 or more meaningful checkpoints
19
+
20
+ Skip the plan only for small, local, low-uncertainty tasks that can be completed quickly.
21
+
22
+ ### Core workflow
23
+
24
+ Follow this workflow:
25
+
26
+ 1. Do a light initial exploration
27
+ 2. Write a high-level plan
28
+ 3. Then repeat for each checkpoint:
29
+ - Explore the checkpoint if needed
30
+ - Update its sub-steps if the route is clearer
31
+ - Execute and validate it
32
+ - Call `show_context`, then either dismiss annotations or summarize completed context
33
+ - Mark the checkpoint complete and move on
34
+
35
+ This is a rolling planning workflow.
36
+
37
+ Do **not** fully audit the codebase before starting.
38
+ Do **not** try to write a detailed implementation spec for every checkpoint up front.
39
+
40
+ Instead:
41
+
42
+ - Explore the whole task just enough to identify the likely route
43
+ - Explore each checkpoint more deeply only when you are about to do it
44
+
45
+ ### Initial exploration
46
+
47
+ Your first exploration pass should be light.
48
+
49
+ Its purpose is to answer:
50
+
51
+ - What is the likely implementation route?
52
+ - Which files or modules are likely to matter?
53
+ - What existing code should probably be reused or mirrored?
54
+ - How will the result be validated?
55
+
56
+ Once those answers are mostly clear, write the plan and begin.
57
+
58
+ Do not stay in exploration mode longer than necessary.
59
+
60
+ ### Checkpoint-level exploration
61
+
62
+ Before starting a checkpoint, explore that checkpoint's implementation path if it is not already clear.
63
+
64
+ This exploration should be narrow and practical.
65
+
66
+ Examples:
67
+
68
+ - Read the exact files you expect to change
69
+ - Find similar implementations to copy or adapt
70
+ - Trace the local call flow for this checkpoint
71
+ - Check how nearby tests are written
72
+ - Confirm what validation command applies to this checkpoint
73
+
74
+ If the checkpoint is already clear, skip extra exploration and execute it directly.
75
+
76
+ ### Using explorers
77
+
78
+ Use `explorer` sub-agents when they help you understand the code faster.
79
+
80
+ Good uses:
81
+
82
+ - The task touches multiple code areas
83
+ - You want to find similar implementations in parallel
84
+ - You want one agent to inspect implementation patterns and another to inspect tests
85
+ - You want to narrow down the right integration point before editing
86
+
87
+ Guidelines:
88
+
89
+ - Prefer the fewest explorers necessary
90
+ - 1 explorer is usually enough
91
+ - Use 2-3 only when the task naturally splits into distinct areas
92
+ - Give each explorer a specific search goal
93
+ - Do not use explorers for trivial lookups in known files
94
+
95
+ Use explorers to support the current checkpoint, not to perform a full codebase audit.
96
+
97
+ ### Creating a plan
98
+
99
+ Write a `.md` plan file in `{SESSION_ARTIFACTS}`.
100
+
101
+ The file must begin with a `## Checkpoints` section.
102
+
103
+ The checkpoints under that header must use Markdown task checkboxes in this exact structure:
104
+
105
+ - Incomplete checkpoint: `- [ ] ...`
106
+ - Completed checkpoint: `- [x] ...`
107
+
108
+ Do not use numbered lists for checkpoints. Do not replace the checkboxes with another format. The progress panel reads this checkbox structure directly.
109
+
110
+ Recommended structure:
111
+
112
+ ```markdown
113
+ ## Checkpoints
114
+ - [ ] Explore the auth flow and define the implementation route
115
+ - [ ] Implement refresh-token expiration handling
116
+ - [ ] Add tests and validate behavior
117
+
118
+ ## Context
119
+ We need to handle expired refresh tokens without falling back to the hardcoded viewer role.
120
+ Expected outcome: expired refresh tokens trigger the existing re-auth path and preserve other auth behavior.
121
+
122
+ ## Key Files
123
+ - `src/auth/provider.ts`
124
+ - `src/auth/errors.ts`
125
+ - `src/auth/guard.ts`
126
+ - `tests/auth-provider.test.ts`
127
+
128
+ ## Explore the auth flow and define the implementation route
129
+ 1. Read `src/auth/provider.ts` and trace refresh token failure handling
130
+ 2. Inspect `src/auth/guard.ts` to find current fallback behavior
131
+ 3. Find an existing auth error propagation pattern to reuse
132
+ 4. Update the next checkpoint with concrete implementation steps
133
+
134
+ ## Implement refresh-token expiration handling
135
+ 1. Confirm where the expiration error is detected
136
+ 2. Add or reuse a specific error type if needed
137
+ 3. Route expired refresh token failures into the existing re-auth flow
138
+ 4. Verify no unrelated auth failures change behavior
139
+
140
+ ## Add tests and validate behavior
141
+ 1. Add focused test coverage for expired refresh tokens
142
+ 2. Update nearby guard tests if behavior changed
143
+ 3. Run focused auth tests
144
+ 4. Do a manual smoke test if applicable
145
+
146
+ ## Validation
147
+ - Run focused auth tests
148
+ - Verify expired refresh tokens trigger re-auth
149
+ - Verify other auth failures behave as before
150
+ ```
151
+
152
+ ### Checkpoint quality
153
+
154
+ Checkpoints should represent meaningful outcomes.
155
+
156
+ Good checkpoints:
157
+
158
+ - Explore the request pipeline and identify the integration point
159
+ - Implement retry behavior for failed uploads
160
+ - Add regression tests and validate the flow
161
+
162
+ Weak checkpoints:
163
+
164
+ - Read code
165
+ - Think
166
+ - Edit file
167
+ - Run command
168
+
169
+ Each checkpoint should produce a visible result or verified milestone.
170
+
171
+ ### Context handling after each checkpoint
172
+
173
+ After each meaningful checkpoint, call `show_context`.
174
+
175
+ Use it to inspect the current active window's context distribution before deciding what to do next.
176
+
177
+ Then choose one of these paths:
178
+
179
+ #### Path A: keep the current context as-is
180
+
181
+ Use this when:
182
+
183
+ - The context is not too large
184
+ - The material is still highly valuable in raw form
185
+ - You expect to refer back to the exact details in the next checkpoint
186
+
187
+ In this case:
188
+
189
+ - Call `show_context(dismiss=true)` to hide the inline annotations
190
+ - Continue to the next checkpoint
191
+
192
+ #### Path B: summarize completed context
193
+
194
+ Use this when:
195
+
196
+ - A checkpoint is complete and its raw exploration or tool output is no longer needed in full
197
+ - The important conclusions are stable
198
+ - A compact summary can preserve what matters better than keeping all raw detail
199
+
200
+ In this case:
201
+
202
+ 1. Use the `show_context` output to identify the relevant context groups
203
+ 2. Write a summary that preserves what future checkpoints will actually need
204
+ 3. Call `summarize_context`
205
+ 4. Continue to the next checkpoint
206
+
207
+ Do **not** try to guess context pressure abstractly. Use `show_context` to make the decision based on the actual context map.
208
+
209
+ ### Summarizing well
210
+
211
+ The goal of summarization is not to make things shorter. The goal is to preserve the right information and let go of raw detail that has served its purpose.
212
+
213
+ A good summary usually keeps:
214
+
215
+ - Architectural findings that later checkpoints depend on
216
+ - Decisions and why they were made
217
+ - Relevant file paths and functions
218
+ - Important edge cases
219
+ - Exact snippets only when they will be needed again
220
+
221
+ A good summary usually drops:
222
+
223
+ - Search process
224
+ - Dead ends that no longer matter
225
+ - Redundant tool output
226
+ - Raw logs whose conclusions are already understood
227
+
228
+ ### Updating the plan
229
+
230
+ The plan is live. Update it when reality changes.
231
+
232
+ Revise it when:
233
+
234
+ - Exploration changes your implementation route
235
+ - You find a better reuse point
236
+ - A checkpoint needs to be split or reordered
237
+ - Validation reveals missing follow-up work
238
+ - The scope changes materially
239
+
240
+ Do not keep following an outdated plan.
241
+
242
+ ### Asking the user
243
+
244
+ Use `ask` only when a concrete user decision is needed and cannot be discovered from the codebase or request. Good cases include choosing between a small number of real implementation options, confirming a product behavior tradeoff, or resolving ambiguity that materially changes the plan. Do not ask the user questions you can answer through exploration.
245
+
246
+ ### Submitting and executing
247
+
248
+ - `plan(action="submit", file="plan.md")` - Activates the plan. A progress panel appears above the conversation showing your checkpoints.
249
+ - `plan(action="check", item=0)` - Marks checkpoint 0 as done (0-based index). The system updates the checkbox in the file and refreshes the panel.
250
+ - `plan(action="finish")` - Dismisses the panel when all work is complete.
251
+
252
+ The plan file is injected into your context every round. Keep it current. You can edit it freely at any time with `edit_file`.
@@ -0,0 +1,9 @@
1
+ ## `read_file`
2
+
3
+ `read_file(path, start_line?, end_line?)`
4
+
5
+ Read text files (max 50 MB). Returns at most 1000 lines / 50,000 chars per call. Use `start_line` / `end_line` to navigate large files in multiple calls.
6
+
7
+ Also reads image files (PNG, JPG, GIF, WebP, BMP, SVG, ICO, TIFF; max 20 MB) when the model supports multimodal input. The image is returned as a visual content block for direct inspection.
8
+
9
+ Returns `mtime_ms` metadata for optional optimistic concurrency checks.
@@ -0,0 +1,12 @@
1
+ ## `show_context`
2
+
3
+ Inspect the current active window's context distribution.
4
+
5
+ The system tracks structured `contextId`s for the active window, but they are **hidden by default** in normal conversation text.
6
+
7
+ - Call `show_context` to reveal all visible context groups, including their IDs, approximate sizes, and what each group covers.
8
+ - Returns a compact **Context Map** showing all context groups with their sizes and types.
9
+ - Makes detailed inline annotations visible at each context group. Annotations remain active until the next `summarize_context` call (auto-dismissed) or until you call `show_context(dismiss=true)`.
10
+ - Use the IDs from `show_context` or from a prior `summarize_context` result as opaque references. They have no semantic ordering.
11
+ - A context group may cover a user message, a tool round, a summary, or compacted continuation context.
12
+ - System messages do not participate in this context grouping scheme.
@@ -0,0 +1,7 @@
1
+ ## `skill`
2
+
3
+ Invoke a skill by name to load specialized instructions. Skills are reusable prompt expansions for specific task types. Pass context via the `arguments` parameter.
4
+
5
+ ## `reload_skills`
6
+
7
+ Rescan skill directories and rebuild the available skills list. Use after installing, removing, or modifying skills on disk. This tool takes no parameters.
@@ -0,0 +1,195 @@
1
+ ## `spawn_agent`
2
+
3
+ Launch sub-agents for bounded, parallel subtasks.
4
+
5
+ ### Two-Step Flow
6
+
7
+ **Step 1.** Write a YAML call file to `{SESSION_ARTIFACTS}`:
8
+
9
+ ```
10
+ write_file(path="{SESSION_ARTIFACTS}/spawn-task.yaml", content=...)
11
+ ```
12
+
13
+ Call file format:
14
+
15
+ ```yaml
16
+ tasks:
17
+ - id: explorer-1
18
+ template: explorer
19
+ task: |
20
+ Explore the providers/ directory at {PROJECT_ROOT}/src/providers/ ...
21
+ ```
22
+
23
+ **Step 2.** Call `spawn_agent(file="spawn-task.yaml")`.
24
+
25
+ The `file` parameter is resolved relative to `{SESSION_ARTIFACTS}` automatically.
26
+
27
+ **Before calling**, re-read your call file — is the task description clear and complete? Does it include enough context, precise scope, and explicit deliverables? A minute spent refining the prompt saves far more time than re-spawning after a poor result.
28
+
29
+ ### Available Pre-defined Templates
30
+
31
+ #### `explorer`
32
+
33
+ Read-only investigation agent. Tools: `read_file`, `list_dir`, `grep`, `glob`, `web_search`, `web_fetch`.
34
+
35
+ Behavioral profile:
36
+ - Focuses on the assigned task, delivers structured findings
37
+ - Uses list_dir for structure, read_file for content, grep/glob for search, web tools for external info
38
+ - Leads with direct answers, includes file paths and code references
39
+ - Understands that only its final text output is visible to you — intermediate tool calls are hidden
40
+ - Has access to the important log for background context
41
+
42
+ Best for: codebase exploration, dependency tracing, pattern searches, code analysis, information gathering. **This is your primary delegation tool — use it liberally.**
43
+
44
+ #### `executor`
45
+
46
+ Task execution agent with file and shell access. Tools: all basic I/O tools (`read_file`, `write_file`, `edit_file`, `apply_patch`, `list_dir`, `glob`, `grep`, `diff`, `bash`, `bash_background`, `bash_output`, `kill_shell`, `test`, `web_search`, `web_fetch`). Does NOT have orchestration tools (cannot spawn sub-agents, manage context, or ask the user).
47
+
48
+ Behavioral profile:
49
+ - Executes bounded tasks with side effects: running tests, making edits, installing dependencies, generating files
50
+ - Examines relevant code before acting, verifies changes when appropriate
51
+ - Reports what was done, what succeeded, and any issues encountered
52
+ - Same output protocol as explorer — final text is the only visible result
53
+ - Has access to the important log for background context
54
+
55
+ Best for: running test suites, applying known edits across files, installing dependencies, generating files, any bounded task requiring bash or file writes.
56
+
57
+ #### Choosing a Template
58
+
59
+ | Need | Template |
60
+ |---|---|
61
+ | Read, search, analyze — no modifications | `explorer` |
62
+ | Run commands, edit files, generate output | `executor` |
63
+ | Neither fits | Create a custom template (rare) |
64
+
65
+ **Strongly prefer `explorer` and `executor` over custom templates.** Only create custom templates when neither predefined template fits your needs.
66
+
67
+ ### Creating Reusable Custom Templates
68
+
69
+ Create a custom template in `{SESSION_ARTIFACTS}`:
70
+
71
+ **Step 1.** Create a template directory with two files:
72
+
73
+ ```
74
+ write_file(path="{SESSION_ARTIFACTS}/my-template/agent.yaml", content=...)
75
+ write_file(path="{SESSION_ARTIFACTS}/my-template/system_prompt.md", content=...)
76
+ ```
77
+
78
+ `agent.yaml` structure:
79
+ ```yaml
80
+ type: agent
81
+ name: my-template
82
+ description: "Brief description of the agent's role."
83
+ system_prompt_file: system_prompt.md
84
+ max_tool_rounds: 100
85
+ ```
86
+
87
+ `max_tool_rounds` is required and must be **>= 100**. Tool set defaults to the same as `executor` when omitted.
88
+
89
+ `system_prompt.md`: Write a focused prompt for the sub-agent's role — include its specific task type, output format expectations, and constraints.
90
+
91
+ **Step 2.** Reference it with `template_path:` in call files:
92
+
93
+ ```yaml
94
+ tasks:
95
+ - id: analyst-1
96
+ template_path: my-template
97
+ task: |
98
+ Analyze the database schema at ...
99
+ ```
100
+
101
+ The template persists in `{SESSION_ARTIFACTS}` for the entire session — you can reuse it across multiple `spawn_agent` calls without recreating it.
102
+
103
+ ### Writing Effective Sub-Agent Prompts
104
+
105
+ The quality of sub-agent results depends almost entirely on your prompt. A well-written task description eliminates the need for you to redo the sub-agent's work.
106
+
107
+ **Structure every task description with these elements:**
108
+
109
+ 1. **Context** — What the sub-agent needs to know: project background, current task, decisions already made. Sub-agents cannot see your conversation.
110
+ 2. **Scope** — Exact files, directories, or code areas to examine. Use full absolute paths. Be explicit about boundaries ("only look at `src/providers/`, do not examine `src/tui/`").
111
+ 3. **Deliverables** — Exactly what format and content you expect back.
112
+ 4. **Constraints** — What to skip, what to prioritize, output length expectations.
113
+
114
+ **Bad prompt vs good prompt:**
115
+
116
+ > `Explore the auth system and tell me what you find.`
117
+ > Produces unfocused noise. You'll waste context reading it and probably re-investigate yourself.
118
+
119
+ > ```
120
+ > Analyze the authentication middleware at {PROJECT_ROOT}/src/middleware/auth/.
121
+ >
122
+ > Context: We're refactoring to support OAuth2 PKCE. Current system uses a strategy pattern.
123
+ >
124
+ > Deliverables:
125
+ > 1. List all strategy classes with file paths and the interface they implement.
126
+ > 2. Identify where the strategy is selected (factory/config).
127
+ > 3. Note existing OAuth support and its limitations.
128
+ > 4. List files that import from the auth module (dependents).
129
+ >
130
+ > Keep response under 500 words. Lead with the strategy interface definition.
131
+ > ```
132
+
133
+ **Share background via important log.** If multiple sub-agents need the same context (project structure, key decisions), write it to your important log first — it's automatically shared with all sub-agents.
134
+
135
+ ### When to Delegate vs Do It Yourself
136
+
137
+ | Delegate | Do it yourself |
138
+ |---|---|
139
+ | Codebase exploration and investigation (explorer) | Sequential edits with dependencies between steps |
140
+ | Understanding code structure, dependencies, patterns (explorer) | Quick single-file lookups at known paths |
141
+ | Reading and analyzing multiple files (explorer) | Iterative back-and-forth with user |
142
+ | Running isolated test suites or builds (executor) | Work that requires ongoing conversation context |
143
+ | Applying well-defined edits across files (executor) | |
144
+ | Generating files from known specifications (executor) | |
145
+
146
+ **Default to delegation.** If a task involves reading or searching more than 1-2 files, spawn a sub-agent. Your job is to orchestrate and execute — not to manually read through codebases.
147
+
148
+ > Need to understand a module? **Spawn an explorer.** Even for seemingly simple questions — the explorer works in its own context and doesn't cost you tokens.
149
+
150
+ > Three independent areas to understand? **Spawn 3 explorers in parallel.** Write one call file with all tasks.
151
+
152
+ > Need one function signature in a file you already know? **Use `read_file` directly.**
153
+
154
+ ### Output Protocol (after spawning sub-agents)
155
+
156
+ **Default behavior: wait.** After spawning sub-agents, you should almost always use `wait`. Do NOT continue working unless you have a genuinely independent task that doesn't depend on the sub-agent results.
157
+
158
+ | Action | When to use |
159
+ |--------|-------------|
160
+ | **`wait`** | **Default.** Your work depends on results, or you have nothing else to do |
161
+ | **Continue working** | **Rare.** Only when you have a truly independent task |
162
+ | **Progress text** | User benefits from an update |
163
+
164
+ > Spawned explorers to understand module structure. **`wait(seconds=60)`** — you need their results before acting.
165
+
166
+ > Spawned auth explorers AND you have a completely unrelated config typo to fix. **Fix the typo** (short, independent), then wait.
167
+
168
+ > Own work done, explorers still running. **Use `wait(seconds=60)`**.
169
+
170
+ ### Processing Sub-Agent Results
171
+
172
+ After receiving results, extract key findings, then compress:
173
+
174
+ > Note the 3-5 key findings, record cross-phase insights in your important log, then `summarize_context` the raw report.
175
+
176
+ > Finished a subtask? Compress its investigation history. Preserve: what was done, key approach, cross-file dependencies still relevant.
177
+
178
+ ### Rules
179
+
180
+ - Wait for all sub-agents before final answer — or kill those you no longer need.
181
+ - Keep concurrent sub-agents to 3-4.
182
+
183
+ ### Anti-patterns
184
+
185
+ - Don't create custom templates when `explorer` or `executor` covers the task — they almost always do.
186
+ - Don't continue working after spawning unless you have a truly independent task.
187
+ - Don't act on assumptions while waiting — if your next step depends on results, wait.
188
+ - Don't over-parallelize — each result needs attention to digest and compress.
189
+ - Don't call `check_status` in a loop — use `wait` instead.
190
+
191
+ ### Patience with Sub-Agents
192
+
193
+ - Sub-agent tasks typically take several minutes. This is normal — don't assume something is wrong after 1 or 2 minutes.
194
+ - Use `wait` with generous timeouts (60-120s). If it times out with agents still working, wait again.
195
+ - Only kill agents when: (a) the task is no longer relevant, or (b) the agent has been doing work for an unreasonably long time with no progress (do NOT kill any agent which works for less than 10 minutes).
@@ -0,0 +1,122 @@
1
+ ## `summarize_context`
2
+
3
+ Replace earlier context with a summary that keeps what's valuable. **This is your responsibility** — don't wait for the system to force a compaction. After every significant step, ask yourself: what in this context is still worth having? Keep that, in whatever length it requires, and let go of the rest.
4
+
5
+ The goal is **not** to make things shorter — it's to keep the right information. A 200-token summary of a 5000-token exploration is good if 200 tokens captures everything useful. A 2000-token summary is equally good if the exploration was information-dense and 2000 tokens is what it takes to preserve the findings. Never compress for the sake of compression.
6
+
7
+ ### How to use
8
+
9
+ **Inline mode** — for quick, straightforward summarizations:
10
+
11
+ ```
12
+ summarize_context(operations=[
13
+ {context_ids: ["a3f1", "7b2e"], summary: "...", reason: "exploration complete"},
14
+ ])
15
+ ```
16
+
17
+ **File mode** — for complex or multi-context summarizations where you want to draft and review before committing:
18
+
19
+ 1. Call `show_context` to see the current distribution.
20
+ 2. Write a `.yaml` summary file to `{SESSION_ARTIFACTS}`:
21
+
22
+ ```yaml
23
+ # {SESSION_ARTIFACTS}/summary.yaml
24
+ operations:
25
+ - context_ids: ["a3f1", "7b2e"]
26
+ reason: "auth exploration complete"
27
+ summary: |
28
+ Architecture of the auth subsystem:
29
+ - `src/auth/provider.ts` — OAuth2 abstraction, Google/GitHub.
30
+ Token refresh in `refreshToken()` (line 82-110).
31
+ - `src/middleware/guard.ts` — Route guard, checks `req.session.roles`.
32
+ Hardcodes fallback role `viewer` at line 67 — this is what we need to change.
33
+ - Code to modify at `src/auth/provider.ts` line 95-103:
34
+ ```typescript
35
+ if (token.exp < now) {
36
+ return this.refreshToken(token.refreshToken);
37
+ }
38
+ ```
39
+ - context_ids: ["d5e6"]
40
+ reason: "config investigation digested"
41
+ summary: |
42
+ Config loading: `src/config/loader.ts` reads `roles.yaml`.
43
+ Custom roles go in the `extensions:` block. No validation on load.
44
+ ```
45
+
46
+ 3. Review what you wrote — **have you preserved all the valuable information?** Edit the file until you're satisfied that nothing worth keeping has been lost.
47
+ 4. Call `summarize_context(file="summary.yaml")`.
48
+
49
+ The system automatically compresses the intermediate steps (file reads, writes, and edits between `show_context` and `summarize_context`) to avoid duplication.
50
+
51
+ **Key rules:**
52
+ - Context IDs must be **spatially contiguous** — no gaps between them.
53
+ - Each operation is validated independently — one failure won't block others.
54
+ - Submit all groups in one call (conversation structure changes after summarization, so sequential calls may target stale positions).
55
+
56
+ ### Writing good summaries
57
+
58
+ A summary replaces the original content permanently within this session. Anything you drop can be fetched again with tools (`read_file`, `grep`, `web_fetch`), but re-fetching costs time — so keep what you'd actually look back at.
59
+
60
+ Summaries can be **any length**. A trivial exchange needs one line; a rich exploration may need a substantial, structured summary. Let the information density of the original — not a compression target — guide the length.
61
+
62
+ **Example A — Condensing a large exploration that's still relevant:**
63
+
64
+ You read 3 files (1200 lines total), ran several greps, and identified an authentication architecture spanning `src/auth/`, `src/middleware/guard.ts`, and `src/config/roles.yaml`. You'll implement changes based on these findings next.
65
+
66
+ > Architecture of the auth subsystem:
67
+ > - `src/auth/provider.ts` — OAuth2 provider abstraction, supports Google/GitHub. Token refresh in `refreshToken()` (line 82-110).
68
+ > - `src/middleware/guard.ts` — Route guard. Checks `req.session.roles` against route metadata. Key function: `checkAccess(route, session)` (line 45).
69
+ > - `src/config/roles.yaml` — Role hierarchy. `admin > editor > viewer`. Custom roles via `extensions:` block.
70
+ > - Discovery: guard.ts hardcodes a fallback role (`viewer`) when session has no roles (line 67). This is the behavior we need to change.
71
+ > - File at `src/auth/provider.ts` line 95-103 has the token validation we'll need to modify:
72
+ > ```typescript
73
+ > if (token.exp < now) {
74
+ > return this.refreshToken(token.refreshToken);
75
+ > }
76
+ > ```
77
+ >
78
+ > Reason: Auth exploration complete, implementation phase next.
79
+
80
+ Note: the summary is long because the findings are rich and directly feed the next step. It preserves a verbatim code snippet that will be needed for `edit_file`.
81
+
82
+ **Example B — Closing a finished phase with little carry-over:**
83
+
84
+ You fixed a CSS bug in `src/ui/panel.tsx`, verified the fix with a test, user confirmed it looks correct. Nothing from this phase is needed going forward.
85
+
86
+ > Fixed vertical overflow in `src/ui/panel.tsx` by changing `height: 100%` to `height: auto` on `.panel-body`. Test added in `panel.test.tsx`. User confirmed fix.
87
+ >
88
+ > Reason: CSS bug fix complete.
89
+
90
+ Short, because there's nothing to carry forward.
91
+
92
+ **Example C — Phase handoff with selective preservation:**
93
+
94
+ You explored three different caching strategies, tried and rejected Redis-based approach (connection pooling issues), decided on in-memory LRU. Next step is implementation.
95
+
96
+ > Caching strategy decision:
97
+ > - **Chosen: in-memory LRU** via `lru-cache` package. Max 500 entries, 5min TTL.
98
+ > - Rejected Redis: connection pooling under high concurrency caused 2-3s stalls in testing. Not viable without major infra changes.
99
+ > - Rejected filesystem cache: too slow for the p95 latency target (< 50ms).
100
+ > - Implementation targets: `src/api/handlers.ts` (wrap `fetchResource()`), `src/cache/lru.ts` (new file).
101
+ >
102
+ > Reason: Caching exploration complete, starting implementation.
103
+
104
+ Preserves the decision and reasoning; drops the exploration steps, Redis config attempts, and benchmark output.
105
+
106
+ **Example D — Summarizing within a plan workflow:**
107
+
108
+ You're executing a plan. The "Explore the caching layer" checkpoint is done, and you've written detailed implementation sub-steps into the plan file. The next checkpoint is "Implement LRU cache". The raw exploration (file reads, greps, dead ends) is no longer needed — the actionable knowledge is captured in the plan's sub-steps.
109
+
110
+ > Exploration of caching layer:
111
+ > - Current cache: naive Map in `src/cache/store.ts`, no eviction, no TTL. Grows unbounded.
112
+ > - Callers: `src/api/handlers.ts:fetchResource()` (line 47), `src/api/handlers.ts:listItems()` (line 112).
113
+ > - `lru-cache` package already in `package.json` (unused, v10.2.0).
114
+ > - No tests for caching behavior currently.
115
+ >
116
+ > Reason: Exploration checkpoint complete, implementation sub-steps written to plan.
117
+
118
+ The summary preserves facts that the implementation steps will reference. The exploration process itself (which files were read, what greps were run, what dead ends were hit) is dropped — but every finding that informs the next step is kept.
119
+
120
+ ### What happens
121
+
122
+ Original messages are replaced by a single summary segment. Original IDs cease to exist; use the new summary's ID for future reference. Summaries can be re-summarized like any other context.
@@ -0,0 +1,5 @@
1
+ ## `test`
2
+
3
+ `test(command?)`
4
+
5
+ Run a test command and return the result. Default: `python -m pytest`.
@@ -0,0 +1,17 @@
1
+ ## `wait`
2
+
3
+ Block until a tracked worker changes state, a new message arrives, or the timeout expires. Tracked workers include sub-agents and background shells. **Always prefer this over `check_status` when you have nothing else to do.**
4
+
5
+ - `seconds` (required, minimum 15): How long to wait.
6
+ - Without `agent`: wall-clock timeout.
7
+ - With `agent`: measures that agent's work time.
8
+ - `agent` (optional): Specific agent ID to wait for.
9
+ - `shell` (optional): Specific background shell ID to monitor.
10
+ - Returns early if ANY agent completes, a tracked shell exits, or a new message arrives.
11
+ - Ordinary shell output does **not** wake `wait`; use `bash_output` to inspect logs.
12
+ - Returns status report with any new messages, sub-agent status, and shell status.
13
+
14
+ > Spawned explorers to understand module structure. **`wait(seconds=60)`** — you need their results before acting.
15
+ > Calling `check_status` in a loop every 10 seconds wastes activations and context.
16
+
17
+ > Waiting specifically for `auth-explorer`? **`wait(seconds=120, agent="auth-explorer")`**.
@@ -0,0 +1,9 @@
1
+ ## `web_fetch`
2
+
3
+ `web_fetch(url, prompt?)`
4
+
5
+ Fetch content from a URL and return it as readable text. HTML pages are converted to markdown-like format.
6
+
7
+ - Only http/https URLs.
8
+ - Use `web_search` to discover URLs; use `web_fetch` to read specific pages.
9
+ - Results may be truncated for very large pages (~100K char limit).
@@ -0,0 +1,5 @@
1
+ ## `web_search`
2
+
3
+ `web_search(query)`
4
+
5
+ Search the web for current information. Returns titles, URLs, and snippets.
@@ -0,0 +1,11 @@
1
+ ## `write_file`
2
+
3
+ `write_file(path, content, expected_mtime_ms?)`
4
+
5
+ Create or overwrite a file. Parent directories are created automatically.
6
+
7
+ ```
8
+ write_file(path="{PROJECT_ROOT}/example.py", content="print('Hello, world!')")
9
+ ```
10
+
11
+ Use `expected_mtime_ms` (from a prior `read_file`) to guard against overwriting concurrent external changes.
File without changes
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: explain-code
3
+ description: Explains code with diagrams and step-by-step analysis. Use when explaining how code works, teaching about a codebase, or when the user asks "how does this work?"
4
+ ---
5
+
6
+ When explaining code, follow this structure:
7
+
8
+ 1. **Analogy**: Compare the code's behavior to something from everyday life
9
+ 2. **Diagram**: Draw an ASCII diagram showing the flow, structure, or relationships
10
+ 3. **Step-by-step walkthrough**: Walk through what happens at each stage
11
+ 4. **Common pitfall**: Highlight one non-obvious mistake or misconception
12
+
13
+ Keep explanations conversational. Adjust depth to match the complexity of the code.
14
+
15
+ If `$ARGUMENTS` refers to a specific file, read it first and then explain it using the structure above.