@esso0428/pi-subagents 0.17.16 → 0.17.18

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 (359) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/ROADMAP.md +87 -0
  3. package/docs/post-0.17.6-agents-roster-viewer-spec.md +42 -0
  4. package/docs/post-0.17.6-durable-history-spec.md +41 -0
  5. package/docs/post-0.17.6-feature-specs.md +50 -0
  6. package/docs/post-0.17.6-nested-agents-spec.md +38 -0
  7. package/docs/post-0.17.6-recovery-shutdown-spec.md +46 -0
  8. package/docs/post-0.17.6-ui-latency-baseline-spec.md +46 -0
  9. package/docs/post-0.17.6-workflow-rpc-lifecycle-spec.md +54 -0
  10. package/package.json +1 -1
  11. package/src/agent-history.ts +2 -54
  12. package/src/agent-manager.ts +406 -1288
  13. package/src/agent-runner.ts +27 -251
  14. package/src/agent-types.ts +32 -188
  15. package/src/cross-extension-rpc.ts +20 -96
  16. package/src/custom-agents.ts +13 -170
  17. package/src/index.ts +480 -1920
  18. package/src/invocation-config.ts +3 -118
  19. package/src/model-resolver.ts +0 -18
  20. package/src/output-file.ts +6 -61
  21. package/src/prompts.ts +2 -45
  22. package/src/schedule.ts +14 -35
  23. package/src/settings.ts +2 -301
  24. package/src/status-note.ts +1 -66
  25. package/src/types.ts +10 -177
  26. package/src/ui/agent-widget.ts +57 -278
  27. package/src/ui/conversation-blocks.ts +0 -6
  28. package/src/ui/conversation-timeline.ts +25 -139
  29. package/src/ui/conversation-viewer.ts +48 -212
  30. package/src/ui/schedule-menu.ts +8 -9
  31. package/src/usage.ts +2 -109
  32. package/src/worktree.ts +55 -69
  33. package/dist/abortable.d.ts +0 -13
  34. package/dist/abortable.d.ts.map +0 -1
  35. package/dist/abortable.js +0 -43
  36. package/dist/abortable.js.map +0 -1
  37. package/dist/agent-color.d.ts +0 -36
  38. package/dist/agent-color.d.ts.map +0 -1
  39. package/dist/agent-color.js +0 -124
  40. package/dist/agent-color.js.map +0 -1
  41. package/dist/agent-file-toggle.d.ts +0 -126
  42. package/dist/agent-file-toggle.d.ts.map +0 -1
  43. package/dist/agent-file-toggle.js +0 -259
  44. package/dist/agent-file-toggle.js.map +0 -1
  45. package/dist/agent-history-list.d.ts +0 -19
  46. package/dist/agent-history-list.d.ts.map +0 -1
  47. package/dist/agent-history-list.js +0 -69
  48. package/dist/agent-history-list.js.map +0 -1
  49. package/dist/agent-history.d.ts +0 -35
  50. package/dist/agent-history.d.ts.map +0 -1
  51. package/dist/agent-history.js +0 -188
  52. package/dist/agent-history.js.map +0 -1
  53. package/dist/agent-manager.d.ts +0 -503
  54. package/dist/agent-manager.d.ts.map +0 -1
  55. package/dist/agent-manager.js +0 -1572
  56. package/dist/agent-manager.js.map +0 -1
  57. package/dist/agent-recovery.d.ts +0 -37
  58. package/dist/agent-recovery.d.ts.map +0 -1
  59. package/dist/agent-recovery.js +0 -171
  60. package/dist/agent-recovery.js.map +0 -1
  61. package/dist/agent-runner.d.ts +0 -303
  62. package/dist/agent-runner.d.ts.map +0 -1
  63. package/dist/agent-runner.js +0 -1003
  64. package/dist/agent-runner.js.map +0 -1
  65. package/dist/agent-types.d.ts +0 -120
  66. package/dist/agent-types.d.ts.map +0 -1
  67. package/dist/agent-types.js +0 -301
  68. package/dist/agent-types.js.map +0 -1
  69. package/dist/child-context.d.ts +0 -3
  70. package/dist/child-context.d.ts.map +0 -1
  71. package/dist/child-context.js +0 -13
  72. package/dist/child-context.js.map +0 -1
  73. package/dist/context.d.ts +0 -13
  74. package/dist/context.d.ts.map +0 -1
  75. package/dist/context.js +0 -57
  76. package/dist/context.js.map +0 -1
  77. package/dist/cross-extension-rpc.d.ts +0 -67
  78. package/dist/cross-extension-rpc.d.ts.map +0 -1
  79. package/dist/cross-extension-rpc.js +0 -139
  80. package/dist/cross-extension-rpc.js.map +0 -1
  81. package/dist/custom-agents.d.ts +0 -55
  82. package/dist/custom-agents.d.ts.map +0 -1
  83. package/dist/custom-agents.js +0 -309
  84. package/dist/custom-agents.js.map +0 -1
  85. package/dist/default-agents.d.ts +0 -8
  86. package/dist/default-agents.d.ts.map +0 -1
  87. package/dist/default-agents.js +0 -123
  88. package/dist/default-agents.js.map +0 -1
  89. package/dist/enabled-models.d.ts +0 -50
  90. package/dist/enabled-models.d.ts.map +0 -1
  91. package/dist/enabled-models.js +0 -146
  92. package/dist/enabled-models.js.map +0 -1
  93. package/dist/env.d.ts +0 -7
  94. package/dist/env.d.ts.map +0 -1
  95. package/dist/env.js +0 -29
  96. package/dist/env.js.map +0 -1
  97. package/dist/group-join.d.ts +0 -33
  98. package/dist/group-join.d.ts.map +0 -1
  99. package/dist/group-join.js +0 -117
  100. package/dist/group-join.js.map +0 -1
  101. package/dist/index.d.ts +0 -51
  102. package/dist/index.d.ts.map +0 -1
  103. package/dist/index.js +0 -3687
  104. package/dist/index.js.map +0 -1
  105. package/dist/invocation-config.d.ts +0 -108
  106. package/dist/invocation-config.d.ts.map +0 -1
  107. package/dist/invocation-config.js +0 -84
  108. package/dist/invocation-config.js.map +0 -1
  109. package/dist/memory.d.ts +0 -54
  110. package/dist/memory.d.ts.map +0 -1
  111. package/dist/memory.js +0 -166
  112. package/dist/memory.js.map +0 -1
  113. package/dist/mention-clone.d.ts +0 -88
  114. package/dist/mention-clone.d.ts.map +0 -1
  115. package/dist/mention-clone.js +0 -154
  116. package/dist/mention-clone.js.map +0 -1
  117. package/dist/mention.d.ts +0 -82
  118. package/dist/mention.d.ts.map +0 -1
  119. package/dist/mention.js +0 -132
  120. package/dist/mention.js.map +0 -1
  121. package/dist/model-resolver.d.ts +0 -37
  122. package/dist/model-resolver.d.ts.map +0 -1
  123. package/dist/model-resolver.js +0 -96
  124. package/dist/model-resolver.js.map +0 -1
  125. package/dist/model-scope.d.ts +0 -50
  126. package/dist/model-scope.d.ts.map +0 -1
  127. package/dist/model-scope.js +0 -49
  128. package/dist/model-scope.js.map +0 -1
  129. package/dist/nested-tools.d.ts +0 -57
  130. package/dist/nested-tools.d.ts.map +0 -1
  131. package/dist/nested-tools.js +0 -301
  132. package/dist/nested-tools.js.map +0 -1
  133. package/dist/nico-overrides.d.ts +0 -54
  134. package/dist/nico-overrides.d.ts.map +0 -1
  135. package/dist/nico-overrides.js +0 -170
  136. package/dist/nico-overrides.js.map +0 -1
  137. package/dist/output-file.d.ts +0 -44
  138. package/dist/output-file.d.ts.map +0 -1
  139. package/dist/output-file.js +0 -156
  140. package/dist/output-file.js.map +0 -1
  141. package/dist/prompts.d.ts +0 -56
  142. package/dist/prompts.d.ts.map +0 -1
  143. package/dist/prompts.js +0 -92
  144. package/dist/prompts.js.map +0 -1
  145. package/dist/schedule-store.d.ts +0 -39
  146. package/dist/schedule-store.d.ts.map +0 -1
  147. package/dist/schedule-store.js +0 -156
  148. package/dist/schedule-store.js.map +0 -1
  149. package/dist/schedule.d.ts +0 -110
  150. package/dist/schedule.d.ts.map +0 -1
  151. package/dist/schedule.js +0 -360
  152. package/dist/schedule.js.map +0 -1
  153. package/dist/settings.d.ts +0 -354
  154. package/dist/settings.d.ts.map +0 -1
  155. package/dist/settings.js +0 -247
  156. package/dist/settings.js.map +0 -1
  157. package/dist/skill-loader.d.ts +0 -25
  158. package/dist/skill-loader.d.ts.map +0 -1
  159. package/dist/skill-loader.js +0 -94
  160. package/dist/skill-loader.js.map +0 -1
  161. package/dist/status-note.d.ts +0 -62
  162. package/dist/status-note.d.ts.map +0 -1
  163. package/dist/status-note.js +0 -86
  164. package/dist/status-note.js.map +0 -1
  165. package/dist/structured-output.d.ts +0 -62
  166. package/dist/structured-output.d.ts.map +0 -1
  167. package/dist/structured-output.js +0 -113
  168. package/dist/structured-output.js.map +0 -1
  169. package/dist/types.d.ts +0 -372
  170. package/dist/types.d.ts.map +0 -1
  171. package/dist/types.js +0 -6
  172. package/dist/types.js.map +0 -1
  173. package/dist/ui/agent-mention.d.ts +0 -83
  174. package/dist/ui/agent-mention.d.ts.map +0 -1
  175. package/dist/ui/agent-mention.js +0 -188
  176. package/dist/ui/agent-mention.js.map +0 -1
  177. package/dist/ui/agent-widget.d.ts +0 -241
  178. package/dist/ui/agent-widget.d.ts.map +0 -1
  179. package/dist/ui/agent-widget.js +0 -992
  180. package/dist/ui/agent-widget.js.map +0 -1
  181. package/dist/ui/ccstyle/diff/ansi-utils.d.ts +0 -11
  182. package/dist/ui/ccstyle/diff/ansi-utils.d.ts.map +0 -1
  183. package/dist/ui/ccstyle/diff/ansi-utils.js +0 -145
  184. package/dist/ui/ccstyle/diff/ansi-utils.js.map +0 -1
  185. package/dist/ui/ccstyle/diff/diff-presentation.d.ts +0 -12
  186. package/dist/ui/ccstyle/diff/diff-presentation.d.ts.map +0 -1
  187. package/dist/ui/ccstyle/diff/diff-presentation.js +0 -48
  188. package/dist/ui/ccstyle/diff/diff-presentation.js.map +0 -1
  189. package/dist/ui/ccstyle/diff/diff-renderer.d.ts +0 -46
  190. package/dist/ui/ccstyle/diff/diff-renderer.d.ts.map +0 -1
  191. package/dist/ui/ccstyle/diff/diff-renderer.js +0 -2049
  192. package/dist/ui/ccstyle/diff/diff-renderer.js.map +0 -1
  193. package/dist/ui/ccstyle/diff/line-width-safety.d.ts +0 -12
  194. package/dist/ui/ccstyle/diff/line-width-safety.d.ts.map +0 -1
  195. package/dist/ui/ccstyle/diff/line-width-safety.js +0 -58
  196. package/dist/ui/ccstyle/diff/line-width-safety.js.map +0 -1
  197. package/dist/ui/ccstyle/diff/render-utils.d.ts +0 -6
  198. package/dist/ui/ccstyle/diff/render-utils.d.ts.map +0 -1
  199. package/dist/ui/ccstyle/diff/render-utils.js +0 -25
  200. package/dist/ui/ccstyle/diff/render-utils.js.map +0 -1
  201. package/dist/ui/ccstyle/diff/shiki-highlight.d.ts +0 -19
  202. package/dist/ui/ccstyle/diff/shiki-highlight.d.ts.map +0 -1
  203. package/dist/ui/ccstyle/diff/shiki-highlight.js +0 -85
  204. package/dist/ui/ccstyle/diff/shiki-highlight.js.map +0 -1
  205. package/dist/ui/ccstyle/diff/types.d.ts +0 -22
  206. package/dist/ui/ccstyle/diff/types.d.ts.map +0 -1
  207. package/dist/ui/ccstyle/diff/types.js +0 -10
  208. package/dist/ui/ccstyle/diff/types.js.map +0 -1
  209. package/dist/ui/ccstyle/diff/write-display-utils.d.ts +0 -2
  210. package/dist/ui/ccstyle/diff/write-display-utils.d.ts.map +0 -1
  211. package/dist/ui/ccstyle/diff/write-display-utils.js +0 -12
  212. package/dist/ui/ccstyle/diff/write-display-utils.js.map +0 -1
  213. package/dist/ui/ccstyle/tool-renderer.d.ts +0 -17
  214. package/dist/ui/ccstyle/tool-renderer.d.ts.map +0 -1
  215. package/dist/ui/ccstyle/tool-renderer.js +0 -74
  216. package/dist/ui/ccstyle/tool-renderer.js.map +0 -1
  217. package/dist/ui/ccstyle/tool-result.d.ts +0 -44
  218. package/dist/ui/ccstyle/tool-result.d.ts.map +0 -1
  219. package/dist/ui/ccstyle/tool-result.js +0 -423
  220. package/dist/ui/ccstyle/tool-result.js.map +0 -1
  221. package/dist/ui/conversation-blocks.d.ts +0 -46
  222. package/dist/ui/conversation-blocks.d.ts.map +0 -1
  223. package/dist/ui/conversation-blocks.js +0 -313
  224. package/dist/ui/conversation-blocks.js.map +0 -1
  225. package/dist/ui/conversation-nvim.d.ts +0 -8
  226. package/dist/ui/conversation-nvim.d.ts.map +0 -1
  227. package/dist/ui/conversation-nvim.js +0 -117
  228. package/dist/ui/conversation-nvim.js.map +0 -1
  229. package/dist/ui/conversation-role.d.ts +0 -13
  230. package/dist/ui/conversation-role.d.ts.map +0 -1
  231. package/dist/ui/conversation-role.js +0 -39
  232. package/dist/ui/conversation-role.js.map +0 -1
  233. package/dist/ui/conversation-search.d.ts +0 -39
  234. package/dist/ui/conversation-search.d.ts.map +0 -1
  235. package/dist/ui/conversation-search.js +0 -124
  236. package/dist/ui/conversation-search.js.map +0 -1
  237. package/dist/ui/conversation-timeline.d.ts +0 -102
  238. package/dist/ui/conversation-timeline.d.ts.map +0 -1
  239. package/dist/ui/conversation-timeline.js +0 -555
  240. package/dist/ui/conversation-timeline.js.map +0 -1
  241. package/dist/ui/conversation-viewer.d.ts +0 -138
  242. package/dist/ui/conversation-viewer.d.ts.map +0 -1
  243. package/dist/ui/conversation-viewer.js +0 -1175
  244. package/dist/ui/conversation-viewer.js.map +0 -1
  245. package/dist/ui/schedule-menu.d.ts +0 -17
  246. package/dist/ui/schedule-menu.d.ts.map +0 -1
  247. package/dist/ui/schedule-menu.js +0 -95
  248. package/dist/ui/schedule-menu.js.map +0 -1
  249. package/dist/ui/select-item.d.ts +0 -28
  250. package/dist/ui/select-item.d.ts.map +0 -1
  251. package/dist/ui/select-item.js +0 -35
  252. package/dist/ui/select-item.js.map +0 -1
  253. package/dist/ui/viewer-keys.d.ts +0 -21
  254. package/dist/ui/viewer-keys.d.ts.map +0 -1
  255. package/dist/ui/viewer-keys.js +0 -18
  256. package/dist/ui/viewer-keys.js.map +0 -1
  257. package/dist/ui/workflow-card.d.ts +0 -176
  258. package/dist/ui/workflow-card.d.ts.map +0 -1
  259. package/dist/ui/workflow-card.js +0 -333
  260. package/dist/ui/workflow-card.js.map +0 -1
  261. package/dist/ui/workflow-dialog.d.ts +0 -306
  262. package/dist/ui/workflow-dialog.d.ts.map +0 -1
  263. package/dist/ui/workflow-dialog.js +0 -844
  264. package/dist/ui/workflow-dialog.js.map +0 -1
  265. package/dist/ui/workflow-menu.d.ts +0 -42
  266. package/dist/ui/workflow-menu.d.ts.map +0 -1
  267. package/dist/ui/workflow-menu.js +0 -127
  268. package/dist/ui/workflow-menu.js.map +0 -1
  269. package/dist/usage.d.ts +0 -136
  270. package/dist/usage.d.ts.map +0 -1
  271. package/dist/usage.js +0 -121
  272. package/dist/usage.js.map +0 -1
  273. package/dist/workflow/collisions.d.ts +0 -96
  274. package/dist/workflow/collisions.d.ts.map +0 -1
  275. package/dist/workflow/collisions.js +0 -89
  276. package/dist/workflow/collisions.js.map +0 -1
  277. package/dist/workflow/entry.d.ts +0 -33
  278. package/dist/workflow/entry.d.ts.map +0 -1
  279. package/dist/workflow/entry.js +0 -30
  280. package/dist/workflow/entry.js.map +0 -1
  281. package/dist/workflow/host.d.ts +0 -63
  282. package/dist/workflow/host.d.ts.map +0 -1
  283. package/dist/workflow/host.js +0 -363
  284. package/dist/workflow/host.js.map +0 -1
  285. package/dist/workflow/journal.d.ts +0 -98
  286. package/dist/workflow/journal.d.ts.map +0 -1
  287. package/dist/workflow/journal.js +0 -121
  288. package/dist/workflow/journal.js.map +0 -1
  289. package/dist/workflow/json-schema.d.ts +0 -52
  290. package/dist/workflow/json-schema.d.ts.map +0 -1
  291. package/dist/workflow/json-schema.js +0 -112
  292. package/dist/workflow/json-schema.js.map +0 -1
  293. package/dist/workflow/meta.d.ts +0 -68
  294. package/dist/workflow/meta.d.ts.map +0 -1
  295. package/dist/workflow/meta.js +0 -318
  296. package/dist/workflow/meta.js.map +0 -1
  297. package/dist/workflow/progress.d.ts +0 -225
  298. package/dist/workflow/progress.d.ts.map +0 -1
  299. package/dist/workflow/progress.js +0 -362
  300. package/dist/workflow/progress.js.map +0 -1
  301. package/dist/workflow/runtime.d.ts +0 -335
  302. package/dist/workflow/runtime.d.ts.map +0 -1
  303. package/dist/workflow/runtime.js +0 -831
  304. package/dist/workflow/runtime.js.map +0 -1
  305. package/dist/workflow/saved.d.ts +0 -91
  306. package/dist/workflow/saved.d.ts.map +0 -1
  307. package/dist/workflow/saved.js +0 -204
  308. package/dist/workflow/saved.js.map +0 -1
  309. package/dist/workflow/task.d.ts +0 -137
  310. package/dist/workflow/task.d.ts.map +0 -1
  311. package/dist/workflow/task.js +0 -208
  312. package/dist/workflow/task.js.map +0 -1
  313. package/dist/workflow/tool-description.d.ts +0 -39
  314. package/dist/workflow/tool-description.d.ts.map +0 -1
  315. package/dist/workflow/tool-description.js +0 -200
  316. package/dist/workflow/tool-description.js.map +0 -1
  317. package/dist/workflow/worker-source.d.ts +0 -48
  318. package/dist/workflow/worker-source.d.ts.map +0 -1
  319. package/dist/workflow/worker-source.js +0 -779
  320. package/dist/workflow/worker-source.js.map +0 -1
  321. package/dist/worktree.d.ts +0 -53
  322. package/dist/worktree.d.ts.map +0 -1
  323. package/dist/worktree.js +0 -165
  324. package/dist/worktree.js.map +0 -1
  325. package/dist/write-execution.d.ts +0 -42
  326. package/dist/write-execution.d.ts.map +0 -1
  327. package/dist/write-execution.js +0 -138
  328. package/dist/write-execution.js.map +0 -1
  329. package/dist/xml.d.ts +0 -11
  330. package/dist/xml.d.ts.map +0 -1
  331. package/dist/xml.js +0 -13
  332. package/dist/xml.js.map +0 -1
  333. package/src/abortable.ts +0 -43
  334. package/src/agent-color.ts +0 -161
  335. package/src/agent-file-toggle.ts +0 -269
  336. package/src/child-context.ts +0 -15
  337. package/src/mention-clone.ts +0 -196
  338. package/src/mention.ts +0 -141
  339. package/src/model-scope.ts +0 -70
  340. package/src/nested-tools.ts +0 -424
  341. package/src/structured-output.ts +0 -130
  342. package/src/ui/agent-mention.ts +0 -216
  343. package/src/ui/select-item.ts +0 -45
  344. package/src/ui/workflow-card.ts +0 -470
  345. package/src/ui/workflow-dialog.ts +0 -1115
  346. package/src/ui/workflow-menu.ts +0 -166
  347. package/src/workflow/collisions.ts +0 -123
  348. package/src/workflow/entry.ts +0 -47
  349. package/src/workflow/host.ts +0 -403
  350. package/src/workflow/journal.ts +0 -164
  351. package/src/workflow/json-schema.ts +0 -128
  352. package/src/workflow/meta.ts +0 -325
  353. package/src/workflow/progress.ts +0 -550
  354. package/src/workflow/runtime.ts +0 -1219
  355. package/src/workflow/saved.ts +0 -217
  356. package/src/workflow/task.ts +0 -302
  357. package/src/workflow/tool-description.ts +0 -200
  358. package/src/workflow/worker-source.ts +0 -781
  359. package/src/xml.ts +0 -13
@@ -1,54 +0,0 @@
1
- /**
2
- * nico-overrides.ts — Read and apply agent overrides from `npm:pi-subagents`-style
3
- * `settings.json` (`subagents.agentOverrides`).
4
- *
5
- * Priority (after `@tintinweb/pi-subagents` has resolved its own .md chain):
6
- * 1. Local JSON (.pi/settings.json) ← highest
7
- * 2. Global JSON (~/.pi/agent/settings.json)
8
- *
9
- * Overrides are applied to matching agents in the registry. If an agent name
10
- * from the overrides does not exist in the registry, it is auto-registered
11
- * using the override fields as the full definition (no .md file needed).
12
- *
13
- * Skill mapping (Nico string[] → tintinweb true | string[] | false):
14
- * ["*"] → true (all skills)
15
- * ["foo"] → ["foo"] (only listed)
16
- * [] | false → false (none)
17
- * omitted → true (all, fallback)
18
- */
19
- import type { AgentConfig } from "./types.js";
20
- export interface NicoAgentOverride {
21
- model?: string | false;
22
- thinking?: string | false;
23
- fallbackModels?: string[];
24
- systemPrompt?: string;
25
- systemPromptMode?: "append" | "replace";
26
- inheritProjectContext?: boolean;
27
- inheritSkills?: boolean;
28
- defaultContext?: "fresh" | "fork" | false;
29
- disabled?: boolean;
30
- skills?: string[] | false;
31
- tools?: string[] | false;
32
- completionGuard?: boolean;
33
- toolBudget?: Record<string, unknown>;
34
- }
35
- /**
36
- * Read subagents.agentOverrides and subagents.defaultModel from both local
37
- * and global Nico-style settings.json. Local overrides global on key collision.
38
- */
39
- export declare function readNicoAgentOverrides(cwd: string): {
40
- overrides: Record<string, NicoAgentOverride>;
41
- defaultModel: string | undefined;
42
- };
43
- export declare function resolveNicoSkills(skills: string[] | false | undefined): true | string[] | false;
44
- /**
45
- * Apply a Nico-style override to an existing tintinweb AgentConfig.
46
- * JSON values directly overwrite the config (highest priority).
47
- */
48
- export declare function applyNicoOverride(agent: AgentConfig, override: NicoAgentOverride, nicoDefaultModel?: string): AgentConfig;
49
- /**
50
- * Apply all Nico overrides to a map of agents (mutating in-place).
51
- * Agents that don't exist yet are auto-registered from the override.
52
- */
53
- export declare function applyNicoOverridesToMap(agents: Map<string, AgentConfig>, overrides: Record<string, NicoAgentOverride>, defaultModel?: string): void;
54
- //# sourceMappingURL=nico-overrides.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nico-overrides.d.ts","sourceRoot":"","sources":["../src/nico-overrides.ts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AAgB,uBAAuB,CACrC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAC5C,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,CASN"}
@@ -1,170 +0,0 @@
1
- /**
2
- * nico-overrides.ts — Read and apply agent overrides from `npm:pi-subagents`-style
3
- * `settings.json` (`subagents.agentOverrides`).
4
- *
5
- * Priority (after `@tintinweb/pi-subagents` has resolved its own .md chain):
6
- * 1. Local JSON (.pi/settings.json) ← highest
7
- * 2. Global JSON (~/.pi/agent/settings.json)
8
- *
9
- * Overrides are applied to matching agents in the registry. If an agent name
10
- * from the overrides does not exist in the registry, it is auto-registered
11
- * using the override fields as the full definition (no .md file needed).
12
- *
13
- * Skill mapping (Nico string[] → tintinweb true | string[] | false):
14
- * ["*"] → true (all skills)
15
- * ["foo"] → ["foo"] (only listed)
16
- * [] | false → false (none)
17
- * omitted → true (all, fallback)
18
- */
19
- import { existsSync, readFileSync } from "node:fs";
20
- import { join } from "node:path";
21
- import { getAgentDir } from "@earendil-works/pi-coding-agent";
22
- import { BUILTIN_TOOL_NAMES } from "./agent-types.js";
23
- // ============================================================================
24
- // Reader
25
- // ============================================================================
26
- /**
27
- * Read subagents.agentOverrides and subagents.defaultModel from both local
28
- * and global Nico-style settings.json. Local overrides global on key collision.
29
- */
30
- export function readNicoAgentOverrides(cwd) {
31
- const merged = {};
32
- let defaultModel;
33
- // Global: ~/.pi/agent/settings.json
34
- const globalPath = join(getAgentDir(), "settings.json");
35
- const globalSettings = readNicoSettingsFile(globalPath);
36
- if (globalSettings) {
37
- mergeOverrides(merged, globalSettings.agentOverrides);
38
- if (defaultModel === undefined)
39
- defaultModel = globalSettings.defaultModel;
40
- }
41
- // Local: .pi/settings.json
42
- const localPath = join(cwd, ".pi", "settings.json");
43
- if (existsSync(localPath)) {
44
- const localSettings = readNicoSettingsFile(localPath);
45
- if (localSettings) {
46
- mergeOverrides(merged, localSettings.agentOverrides);
47
- if (localSettings.defaultModel !== undefined)
48
- defaultModel = localSettings.defaultModel;
49
- }
50
- }
51
- return { overrides: merged, defaultModel };
52
- }
53
- function readNicoSettingsFile(filePath) {
54
- if (!existsSync(filePath))
55
- return undefined;
56
- try {
57
- const raw = JSON.parse(readFileSync(filePath, "utf-8"));
58
- const sub = raw?.subagents;
59
- if (!sub || typeof sub !== "object")
60
- return undefined;
61
- return sub;
62
- }
63
- catch {
64
- // Silently skip — bad Nico config must not break tintinweb
65
- return undefined;
66
- }
67
- }
68
- function mergeOverrides(target, source) {
69
- if (!source)
70
- return;
71
- for (const [name, override] of Object.entries(source)) {
72
- target[name] = { ...target[name], ...override };
73
- }
74
- }
75
- // ============================================================================
76
- // Skill converter: Nico string[] → tintinweb true | string[] | false
77
- // ============================================================================
78
- export function resolveNicoSkills(skills) {
79
- // Not set → inherit all (tintinweb default)
80
- if (skills === undefined)
81
- return true;
82
- // Explicit false / empty array → none
83
- if (skills === false || skills.length === 0)
84
- return false;
85
- // ["*"] → all skills
86
- if (skills.length === 1 && skills[0] === "*")
87
- return true;
88
- // Specific list
89
- return [...skills];
90
- }
91
- // ============================================================================
92
- // Applier — override existing agent
93
- // ============================================================================
94
- /**
95
- * Apply a Nico-style override to an existing tintinweb AgentConfig.
96
- * JSON values directly overwrite the config (highest priority).
97
- */
98
- export function applyNicoOverride(agent, override, nicoDefaultModel) {
99
- let modified = false;
100
- let next = agent;
101
- // model: explicit override wins; else use defaultModel when agent has none
102
- if (override.model !== undefined) {
103
- next = { ...next, model: override.model === false ? undefined : override.model };
104
- modified = true;
105
- }
106
- else if (nicoDefaultModel !== undefined && next.model === undefined) {
107
- next = { ...next, model: nicoDefaultModel };
108
- modified = true;
109
- }
110
- if (override.thinking !== undefined) {
111
- next = { ...next, thinking: override.thinking === false ? undefined : override.thinking };
112
- modified = true;
113
- }
114
- if (override.systemPrompt !== undefined) {
115
- next = { ...next, systemPrompt: override.systemPrompt };
116
- modified = true;
117
- }
118
- if (override.disabled !== undefined) {
119
- next = { ...next, enabled: !override.disabled };
120
- modified = true;
121
- }
122
- if (override.tools !== undefined) {
123
- next = { ...next, builtinToolNames: override.tools === false ? [] : [...override.tools] };
124
- modified = true;
125
- }
126
- return modified ? next : agent;
127
- }
128
- // ============================================================================
129
- // Auto-register — create AgentConfig from override when agent doesn't exist
130
- // ============================================================================
131
- function createAgentFromOverride(name, override, defaultModel) {
132
- return {
133
- name,
134
- displayName: name,
135
- description: `Auto-registered from npm:pi-subagents JSON settings`,
136
- builtinToolNames: override.tools !== undefined
137
- ? (override.tools === false ? [] : [...override.tools])
138
- : [...BUILTIN_TOOL_NAMES],
139
- extensions: true,
140
- skills: resolveNicoSkills(override.skills),
141
- model: override.model !== undefined ? (override.model === false ? undefined : override.model) : defaultModel,
142
- thinking: override.thinking !== undefined
143
- ? (override.thinking === false ? undefined : override.thinking)
144
- : undefined,
145
- systemPrompt: override.systemPrompt ?? "",
146
- promptMode: override.systemPromptMode === "append" ? "append" : "replace",
147
- enabled: !(override.disabled ?? false),
148
- source: "global",
149
- isDefault: false,
150
- };
151
- }
152
- // ============================================================================
153
- // Bulk apply
154
- // ============================================================================
155
- /**
156
- * Apply all Nico overrides to a map of agents (mutating in-place).
157
- * Agents that don't exist yet are auto-registered from the override.
158
- */
159
- export function applyNicoOverridesToMap(agents, overrides, defaultModel) {
160
- for (const [name, override] of Object.entries(overrides)) {
161
- const existing = agents.get(name);
162
- if (existing) {
163
- agents.set(name, applyNicoOverride(existing, override, defaultModel));
164
- }
165
- else {
166
- agents.set(name, createAgentFromOverride(name, override, defaultModel));
167
- }
168
- }
169
- }
170
- //# sourceMappingURL=nico-overrides.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nico-overrides.js","sourceRoot":"","sources":["../src/nico-overrides.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,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,QAAQ,CAAC,YAAY,IAAI,EAAE;QACzC,UAAU,EAAE,QAAQ,CAAC,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QACzE,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,IAAI,KAAK,CAAC;QACtC,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,KAAK;KACjB,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAgC,EAChC,SAA4C,EAC5C,YAAqB;IAErB,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,uBAAuB,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,44 +0,0 @@
1
- /**
2
- * output-file.ts — Streaming JSONL output file for agent transcripts.
3
- *
4
- * Creates a per-agent output file that streams conversation turns as JSONL,
5
- * matching Claude Code's task output file format.
6
- */
7
- import type { AgentSession } from "@earendil-works/pi-coding-agent";
8
- export declare function getOutputTranscriptDefault(): boolean;
9
- export declare function setOutputTranscriptDefault(b: boolean): void;
10
- /**
11
- * Encode a cwd path as a filesystem-safe directory name. Handles:
12
- * - POSIX: "/home/user/project" → "home-user-project"
13
- * - Windows: "C:\Users\foo\project" → "Users-foo-project"
14
- * - UNC: "\\\\server\\share\\project" → "server-share-project"
15
- */
16
- export declare function encodeCwd(cwd: string): string;
17
- /**
18
- * The per-session scratch directory, created if missing.
19
- * Mirrors Claude Code's layout: /tmp/{prefix}-{uid}/{encoded-cwd}/{sessionId}/tasks
20
- *
21
- * Shared with the workflow tool, which persists each invocation's script here so
22
- * iterating on one is edit-file-then-rerun — the same convention, one directory.
23
- */
24
- export declare function sessionTaskDir(cwd: string, sessionId: string): string;
25
- /** Create the output file path, ensuring the directory exists. */
26
- export declare function createOutputFilePath(cwd: string, agentId: string, sessionId: string): string;
27
- /**
28
- * Ensure a transcript file exists without disturbing what is already in it.
29
- *
30
- * A resume reuses the agent's existing transcript (same deterministic path), so
31
- * it must never call `writeInitialEntry` — that truncates, discarding turns the
32
- * completion notification still points the user at, and any history the session
33
- * has since compacted away is gone for good. Appending nothing creates the file
34
- * when this is the agent's first transcript and is a no-op when it is not.
35
- */
36
- export declare function ensureOutputFile(path: string): void;
37
- /** Write the initial user prompt entry. */
38
- export declare function writeInitialEntry(path: string, agentId: string, prompt: string, cwd: string): void;
39
- /**
40
- * Subscribe to session events and flush new messages to the output file on each turn_end.
41
- * Returns a cleanup function that does a final flush and unsubscribes.
42
- */
43
- export declare function streamToOutputFile(session: AgentSession, path: string, agentId: string, cwd: string, startIndexOrHistoryPath?: number | string, historyPath?: string): () => void;
44
- //# sourceMappingURL=output-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"output-file.d.ts","sourceRoot":"","sources":["../src/output-file.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,iCAAiC,CAAC;AAavF,wBAAgB,0BAA0B,IAAI,OAAO,CAAoC;AACzF,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAiC;AAE7F;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAcrE;AAED,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAInD;AAED,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAUlG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,uBAAuB,CAAC,EAAE,MAAM,GAAG,MAAM,EACzC,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,IAAI,CA8DZ"}
@@ -1,156 +0,0 @@
1
- /**
2
- * output-file.ts — Streaming JSONL output file for agent transcripts.
3
- *
4
- * Creates a per-agent output file that streams conversation turns as JSONL,
5
- * matching Claude Code's task output file format.
6
- */
7
- import { appendFileSync, chmodSync, mkdirSync, writeFileSync } from "node:fs";
8
- import { tmpdir } from "node:os";
9
- import { join } from "node:path";
10
- /**
11
- * Project/global default for writing a subagent's `.output` transcript; a custom
12
- * agent's `output_transcript` overrides it per agent.
13
- *
14
- * State lives here rather than in an index.ts closure because both spawn paths
15
- * need it — the top-level Agent tool and the nested delegation tools. Same
16
- * reason `scopeModels` lives in model-scope.ts: a setting only one path can read
17
- * is a setting the other path silently ignores.
18
- */
19
- let outputTranscriptDefault = true;
20
- export function getOutputTranscriptDefault() { return outputTranscriptDefault; }
21
- export function setOutputTranscriptDefault(b) { outputTranscriptDefault = b; }
22
- /**
23
- * Encode a cwd path as a filesystem-safe directory name. Handles:
24
- * - POSIX: "/home/user/project" → "home-user-project"
25
- * - Windows: "C:\Users\foo\project" → "Users-foo-project"
26
- * - UNC: "\\\\server\\share\\project" → "server-share-project"
27
- */
28
- export function encodeCwd(cwd) {
29
- return cwd
30
- .replace(/[/\\]/g, "-") // both separators → dash
31
- .replace(/^[A-Za-z]:-/, "") // strip Windows drive prefix ("C:-")
32
- .replace(/^-+/, ""); // strip leading dashes (POSIX root, UNC)
33
- }
34
- /**
35
- * The per-session scratch directory, created if missing.
36
- * Mirrors Claude Code's layout: /tmp/{prefix}-{uid}/{encoded-cwd}/{sessionId}/tasks
37
- *
38
- * Shared with the workflow tool, which persists each invocation's script here so
39
- * iterating on one is edit-file-then-rerun — the same convention, one directory.
40
- */
41
- export function sessionTaskDir(cwd, sessionId) {
42
- const encoded = encodeCwd(cwd);
43
- const root = join(tmpdir(), `pi-subagents-${process.getuid?.() ?? 0}`);
44
- mkdirSync(root, { recursive: true, mode: 0o700 });
45
- // chmod is a no-op on Windows and throws on some Windows filesystems.
46
- // On Unix we still want to enforce 0o700 past umask, so only swallow on Windows.
47
- try {
48
- chmodSync(root, 0o700);
49
- }
50
- catch (err) {
51
- if (process.platform !== "win32")
52
- throw err;
53
- }
54
- const dir = join(root, encoded, sessionId, "tasks");
55
- mkdirSync(dir, { recursive: true });
56
- return dir;
57
- }
58
- /** Create the output file path, ensuring the directory exists. */
59
- export function createOutputFilePath(cwd, agentId, sessionId) {
60
- return join(sessionTaskDir(cwd, sessionId), `${agentId}.output`);
61
- }
62
- /**
63
- * Ensure a transcript file exists without disturbing what is already in it.
64
- *
65
- * A resume reuses the agent's existing transcript (same deterministic path), so
66
- * it must never call `writeInitialEntry` — that truncates, discarding turns the
67
- * completion notification still points the user at, and any history the session
68
- * has since compacted away is gone for good. Appending nothing creates the file
69
- * when this is the agent's first transcript and is a no-op when it is not.
70
- */
71
- export function ensureOutputFile(path) {
72
- try {
73
- appendFileSync(path, "", "utf-8");
74
- }
75
- catch { /* ignore — streaming writes are best-effort too */ }
76
- }
77
- /** Write the initial user prompt entry. */
78
- export function writeInitialEntry(path, agentId, prompt, cwd) {
79
- const entry = {
80
- isSidechain: true,
81
- agentId,
82
- type: "user",
83
- message: { role: "user", content: prompt },
84
- timestamp: new Date().toISOString(),
85
- cwd,
86
- };
87
- writeFileSync(path, JSON.stringify(entry) + "\n", "utf-8");
88
- }
89
- /**
90
- * Subscribe to session events and flush new messages to the output file on each turn_end.
91
- * Returns a cleanup function that does a final flush and unsubscribes.
92
- */
93
- export function streamToOutputFile(session, path, agentId, cwd, startIndexOrHistoryPath, historyPath) {
94
- // Keep the fork's historical five-argument form (historyPath as the fifth
95
- // argument) while accepting upstream's six-argument resume form
96
- // (startIndex, historyPath). This matters because scheduler/RPC/workflow
97
- // callers use the ordinary spawn form, whereas resume starts after an
98
- // existing in-memory message prefix.
99
- const startIndex = typeof startIndexOrHistoryPath === "number" ? startIndexOrHistoryPath : undefined;
100
- const durableHistoryPath = typeof startIndexOrHistoryPath === "string"
101
- ? startIndexOrHistoryPath
102
- : historyPath;
103
- // Index of the first message this stream is responsible for. A spawn writes
104
- // messages[0] as the initial prompt entry, so it starts at 1. A resume hands
105
- // in the session's length as of just before the run: the session already
106
- // holds every prior turn, and re-emitting those would duplicate history that
107
- // is already in the file.
108
- let writtenCount = startIndex ?? 1;
109
- const flush = () => {
110
- const messages = session.messages;
111
- while (writtenCount < messages.length) {
112
- const msg = messages[writtenCount];
113
- const entry = {
114
- isSidechain: true,
115
- agentId,
116
- type: msg.role === "assistant" ? "assistant" : msg.role === "user" ? "user" : "toolResult",
117
- message: msg,
118
- timestamp: new Date().toISOString(),
119
- cwd,
120
- };
121
- const entryJson = JSON.stringify(entry) + "\n";
122
- const targets = durableHistoryPath && durableHistoryPath !== path ? [path, durableHistoryPath] : [path];
123
- for (const target of targets) {
124
- try {
125
- appendFileSync(target, entryJson, "utf-8");
126
- }
127
- catch { /* ignore write errors */ }
128
- }
129
- writtenCount++;
130
- }
131
- };
132
- const unsubscribe = session.subscribe((event) => {
133
- if (event.type === "turn_end")
134
- flush();
135
- // Compaction replaces session.messages with a shorter, summarized array,
136
- // leaving writtenCount past the new end — without re-anchoring, the flush
137
- // loop would never match again and streaming would halt for good (#145).
138
- // Flush before it runs so any not-yet-flushed tail still reaches the file,
139
- // then re-anchor to the rebuilt array once it lands. The re-anchor is
140
- // deferred a microtask because on the overflow-retry path pi trims the
141
- // trailing error assistant message AFTER emitting compaction_end —
142
- // anchoring synchronously would sit one past the trimmed array and skip
143
- // the first post-compaction message. Aborted/failed compactions leave
144
- // session.messages untouched, so only successful ones re-anchor.
145
- if (event.type === "compaction_start")
146
- flush();
147
- if (event.type === "compaction_end" && !event.aborted && event.result) {
148
- queueMicrotask(() => { writtenCount = session.messages.length; });
149
- }
150
- });
151
- return () => {
152
- flush();
153
- unsubscribe();
154
- };
155
- }
156
- //# sourceMappingURL=output-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"output-file.js","sourceRoot":"","sources":["../src/output-file.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;;;;;;GAQG;AACH,IAAI,uBAAuB,GAAG,IAAI,CAAC;AAEnC,MAAM,UAAU,0BAA0B,KAAc,OAAO,uBAAuB,CAAC,CAAC,CAAC;AACzF,MAAM,UAAU,0BAA0B,CAAC,CAAU,IAAU,uBAAuB,GAAG,CAAC,CAAC,CAAC,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,GAAG;SACP,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAQ,yBAAyB;SACvD,OAAO,CAAC,aAAa,EAAE,EAA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YACtE,cAAc,CAAC,GAAG,EAAE,GAAG,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,KAAK,EAAE,CAAC;QACR,WAAW,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
package/dist/prompts.d.ts DELETED
@@ -1,56 +0,0 @@
1
- /**
2
- * prompts.ts — System prompt builder for agents.
3
- */
4
- import type { AgentConfig, EnvInfo } from "./types.js";
5
- /** Extra sections to inject into the system prompt (memory, skills, etc.). */
6
- export interface PromptExtras {
7
- /** Persistent memory content to inject (first 200 lines of MEMORY.md + instructions). */
8
- memoryBlock?: string;
9
- /** Preloaded skill contents to inject. */
10
- skillBlocks?: {
11
- name: string;
12
- content: string;
13
- }[];
14
- /**
15
- * Parent directory the worktree copy was created from. Set only for
16
- * `isolation: "worktree"` spawns — triggers the block that tells the agent
17
- * to stay in the copy.
18
- */
19
- worktreeBase?: string;
20
- /**
21
- * Set only for a workflow's own children, and only when they have no
22
- * `StructuredOutput` tool to answer through.
23
- *
24
- * A workflow child's final text is not read by a human — it is the value
25
- * `agent()` resolves to, and the script interpolates it straight into the
26
- * next stage's prompt. Without this, children answer the way every other
27
- * subagent does (a report addressed to a reader), and the padding becomes
28
- * input tokens for the stage downstream. Claude Code's `Workflow` tool
29
- * documents this contract to the script-writing model; this is the end of it
30
- * that makes the documentation true.
31
- *
32
- * Deliberately NOT applied to every subagent. In pi an ordinary agent's
33
- * output IS read by a human — through the Agents widget, the conversation
34
- * viewer and `get_subagent_result` — so terse raw data would be wrong there.
35
- */
36
- workflowChild?: boolean;
37
- }
38
- /**
39
- * Build the system prompt for an agent from its config.
40
- *
41
- * - "replace" mode: env header + config.systemPrompt (full control, no parent identity)
42
- * - "append" mode: parent system prompt + sub-agent context + env header + config.systemPrompt
43
- * - "append" with empty systemPrompt: pure parent clone
44
- *
45
- * Both modes include an `<active_agent name="${config.name}"/>` tag so downstream
46
- * extensions (e.g. permission/policy systems) can resolve per-agent policy
47
- * inside the child session by parsing the system prompt. In replace mode the tag
48
- * is prepended; in append mode it follows the shared inherited content so the
49
- * parent prompt forms an identical, cacheable byte prefix with the parent
50
- * session (the LLM's KV cache can then reuse those tokens across every spawn).
51
- *
52
- * @param parentSystemPrompt The parent agent's effective system prompt (for append mode).
53
- * @param extras Optional extra sections to inject (memory, preloaded skills).
54
- */
55
- export declare function buildAgentPrompt(config: AgentConfig, cwd: string, env: EnvInfo, parentSystemPrompt?: string, extras?: PromptExtras): string;
56
- //# sourceMappingURL=prompts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEvD,8EAA8E;AAC9E,MAAM,WAAW,YAAY;IAC3B,yFAAyF;IACzF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAClD;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;;;;OAeG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,OAAO,EACZ,kBAAkB,CAAC,EAAE,MAAM,EAC3B,MAAM,CAAC,EAAE,YAAY,GACpB,MAAM,CA2ER"}
package/dist/prompts.js DELETED
@@ -1,92 +0,0 @@
1
- /**
2
- * prompts.ts — System prompt builder for agents.
3
- */
4
- /**
5
- * Build the system prompt for an agent from its config.
6
- *
7
- * - "replace" mode: env header + config.systemPrompt (full control, no parent identity)
8
- * - "append" mode: parent system prompt + sub-agent context + env header + config.systemPrompt
9
- * - "append" with empty systemPrompt: pure parent clone
10
- *
11
- * Both modes include an `<active_agent name="${config.name}"/>` tag so downstream
12
- * extensions (e.g. permission/policy systems) can resolve per-agent policy
13
- * inside the child session by parsing the system prompt. In replace mode the tag
14
- * is prepended; in append mode it follows the shared inherited content so the
15
- * parent prompt forms an identical, cacheable byte prefix with the parent
16
- * session (the LLM's KV cache can then reuse those tokens across every spawn).
17
- *
18
- * @param parentSystemPrompt The parent agent's effective system prompt (for append mode).
19
- * @param extras Optional extra sections to inject (memory, preloaded skills).
20
- */
21
- export function buildAgentPrompt(config, cwd, env, parentSystemPrompt, extras) {
22
- const activeAgentTag = `<active_agent name="${config.name}"/>\n\n`;
23
- const envBlock = `# Environment
24
- Working directory: ${cwd}
25
- ${env.isGitRepo ? `Git repository: yes\nBranch: ${env.branch}` : "Not a git repository"}
26
- Platform: ${env.platform}`;
27
- // A worktree agent is told its cwd twice: by the env block above (the copy)
28
- // and by whatever names the main checkout — the inherited parent prompt in
29
- // append mode, or the task prompt in either mode. It follows the latter and
30
- // works in the shared tree (#187), so resolve the contradiction explicitly.
31
- const worktreeBlock = extras?.worktreeBase
32
- ? `\n\n<worktree_isolation>
33
- Your working directory is an isolated git worktree copy of ${extras.worktreeBase}.
34
- Work only inside it — never in ${extras.worktreeBase}, even if other instructions name that path as your working directory.
35
- </worktree_isolation>`
36
- : "";
37
- // The script, not a person, reads what this child returns — see
38
- // `PromptExtras.workflowChild` for why only workflow children get this.
39
- const workflowBlock = extras?.workflowChild
40
- ? `\n\n<workflow_child>
41
- Your final message IS the return value of this task. A workflow script captures it and passes it to the next stage; no person reads it.
42
- Return only the answer, in exactly the shape the prompt asks for — no preamble, no summary of what you did, no offer to continue.
43
- </workflow_child>`
44
- : "";
45
- // Build optional extras suffix
46
- const extraSections = [];
47
- if (extras?.memoryBlock) {
48
- extraSections.push(extras.memoryBlock);
49
- }
50
- if (extras?.skillBlocks?.length) {
51
- for (const skill of extras.skillBlocks) {
52
- extraSections.push(`\n# Preloaded Skill: ${skill.name}\n${skill.content}`);
53
- }
54
- }
55
- const extrasSuffix = extraSections.length > 0 ? "\n\n" + extraSections.join("\n") : "";
56
- if (config.promptMode === "append") {
57
- const identity = parentSystemPrompt || genericBase;
58
- const bridge = `<sub_agent_context>
59
- You are operating as a sub-agent invoked to handle a specific task.
60
- - Use the read tool instead of cat/head/tail
61
- - Use the edit tool instead of sed/awk
62
- - Use the write tool instead of echo/heredoc
63
- - Use the find tool instead of bash find/ls for file search
64
- - Use the grep tool instead of bash grep/rg for content search
65
- - Make independent tool calls in parallel
66
- - Use absolute file paths
67
- - Do not use emojis
68
- - Be concise but complete
69
- </sub_agent_context>`;
70
- const customSection = config.systemPrompt?.trim()
71
- ? `\n\n<agent_instructions>\n${config.systemPrompt}\n</agent_instructions>`
72
- : "";
73
- // Place shared/stable content first so the LLM's KV cache can reuse the
74
- // inherited prefix across all subagent invocations. The parent prompt is
75
- // placed verbatim (no wrapper tag) so it forms an identical byte prefix
76
- // with the parent session, maximising KV cache hits. The <active_agent>
77
- // tag and env block vary per call and are placed after the cached prefix.
78
- return identity + "\n\n" + bridge + "\n\n" + activeAgentTag + envBlock + worktreeBlock + workflowBlock + customSection + extrasSuffix;
79
- }
80
- // "replace" mode — env header + the config's full system prompt
81
- const replaceHeader = `You are a pi coding agent sub-agent.
82
- You have been invoked to handle a specific task autonomously.
83
-
84
- ${envBlock}`;
85
- return activeAgentTag + replaceHeader + worktreeBlock + workflowBlock + "\n\n" + config.systemPrompt + extrasSuffix;
86
- }
87
- /** Fallback base prompt when parent system prompt is unavailable in append mode. */
88
- const genericBase = `# Role
89
- You are a general-purpose coding agent for complex, multi-step tasks.
90
- You have full access to read, write, edit files, and execute commands.
91
- Do what has been asked; nothing more, nothing less.`;
92
- //# sourceMappingURL=prompts.js.map
@@ -1 +0,0 @@
1
- {"version":3,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C,CAAC,CAAC,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEvF,IAAI,MAAM,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,kBAAkB,IAAI,WAAW,CAAC;QAEnD,MAAM,MAAM,GAAG;;;;;;;;;;;qBAWE,CAAC;QAElB,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE;YAC/C,CAAC,CAAC,6BAA6B,MAAM,CAAC,YAAY,yBAAyB;YAC3E,CAAC,CAAC,EAAE,CAAC;QAEP,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,wEAAwE;QACxE,0EAA0E;QAC1E,OAAO,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,cAAc,GAAG,QAAQ,GAAG,aAAa,GAAG,aAAa,GAAG,aAAa,GAAG,YAAY,CAAC;IACxI,CAAC;IAED,gEAAgE;IAChE,MAAM,aAAa,GAAG;;;EAGtB,QAAQ,EAAE,CAAC;IAEX,OAAO,cAAc,GAAG,aAAa,GAAG,aAAa,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;AACtH,CAAC;AAED,oFAAoF;AACpF,MAAM,WAAW,GAAG;;;oDAGgC,CAAC"}
@@ -1,39 +0,0 @@
1
- /**
2
- * schedule-store.ts — File-backed store for scheduled subagents.
3
- *
4
- * Session-scoped: each pi session owns its own schedules at
5
- * `<cwd>/.pi/subagent-schedules/<sessionId>.json`. `/new` starts a fresh
6
- * empty store; `/resume` reloads.
7
- *
8
- * Concurrency model lifted from pi-chonky-tasks/src/task-store.ts: every
9
- * mutation acquires a PID-based exclusion lock, re-reads the latest state
10
- * from disk, applies the change, atomic-writes via temp+rename, releases.
11
- */
12
- import type { ScheduledSubagent } from "./types.js";
13
- /** Resolve the storage path for a session-scoped store. */
14
- export declare function resolveStorePath(cwd: string, sessionId: string): string;
15
- export declare class ScheduleStore {
16
- private filePath;
17
- private lockPath;
18
- private jobs;
19
- constructor(filePath: string);
20
- /** Create the backing directory lazily — only when we're about to persist. */
21
- private ensureDir;
22
- /** Load from disk into the in-memory cache. Silent on parse errors. */
23
- private load;
24
- /** Atomic write via temp file + rename (POSIX-atomic). */
25
- private save;
26
- /** Acquire lock → reload → mutate → save → release. */
27
- private withLock;
28
- /** Read-only — returns a snapshot of the in-memory cache. */
29
- list(): ScheduledSubagent[];
30
- /** Read-only check — uses the cache. */
31
- hasName(name: string, exceptId?: string): boolean;
32
- get(id: string): ScheduledSubagent | undefined;
33
- add(job: ScheduledSubagent): void;
34
- update(id: string, patch: Partial<ScheduledSubagent>): ScheduledSubagent | undefined;
35
- remove(id: string): boolean;
36
- /** Delete the backing file (used when no jobs remain, optional cleanup). */
37
- deleteFileIfEmpty(): void;
38
- }
39
- //# sourceMappingURL=schedule-store.d.ts.map