@codemieai/code 0.11.0 → 0.13.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 (253) hide show
  1. package/README.md +109 -56
  2. package/bin/codemie-copilot.js +224 -0
  3. package/bin/codemie-pi.js +18 -0
  4. package/dist/agents/core/AgentCLI.d.ts.map +1 -1
  5. package/dist/agents/core/AgentCLI.js +16 -10
  6. package/dist/agents/core/AgentCLI.js.map +1 -1
  7. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  8. package/dist/agents/core/BaseAgentAdapter.js +43 -19
  9. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  10. package/dist/agents/core/agent-aliases.d.ts +17 -0
  11. package/dist/agents/core/agent-aliases.d.ts.map +1 -0
  12. package/dist/agents/core/agent-aliases.js +41 -0
  13. package/dist/agents/core/agent-aliases.js.map +1 -0
  14. package/dist/agents/core/session/BaseSessionAdapter.d.ts +19 -0
  15. package/dist/agents/core/session/BaseSessionAdapter.d.ts.map +1 -1
  16. package/dist/agents/core/session/session-origin-audit.d.ts +13 -0
  17. package/dist/agents/core/session/session-origin-audit.d.ts.map +1 -1
  18. package/dist/agents/core/session/session-origin-audit.js +34 -0
  19. package/dist/agents/core/session/session-origin-audit.js.map +1 -1
  20. package/dist/agents/core/session/stale-session-reconciliation.d.ts +42 -0
  21. package/dist/agents/core/session/stale-session-reconciliation.d.ts.map +1 -0
  22. package/dist/agents/core/session/stale-session-reconciliation.js +141 -0
  23. package/dist/agents/core/session/stale-session-reconciliation.js.map +1 -0
  24. package/dist/agents/core/session/types.d.ts +19 -0
  25. package/dist/agents/core/session/types.d.ts.map +1 -1
  26. package/dist/agents/core/session/types.js +17 -1
  27. package/dist/agents/core/session/types.js.map +1 -1
  28. package/dist/agents/core/types.d.ts +11 -0
  29. package/dist/agents/core/types.d.ts.map +1 -1
  30. package/dist/agents/plugins/codex/codex.reconciliation.d.ts +15 -35
  31. package/dist/agents/plugins/codex/codex.reconciliation.d.ts.map +1 -1
  32. package/dist/agents/plugins/codex/codex.reconciliation.js +8 -139
  33. package/dist/agents/plugins/codex/codex.reconciliation.js.map +1 -1
  34. package/dist/agents/plugins/copilot-cli/copilot-cli-event-types.d.ts +146 -0
  35. package/dist/agents/plugins/copilot-cli/copilot-cli-event-types.d.ts.map +1 -0
  36. package/dist/agents/plugins/copilot-cli/copilot-cli-event-types.js +12 -0
  37. package/dist/agents/plugins/copilot-cli/copilot-cli-event-types.js.map +1 -0
  38. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts +15 -0
  39. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts.map +1 -0
  40. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js +15 -0
  41. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js.map +1 -0
  42. package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts +8 -0
  43. package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts.map +1 -0
  44. package/dist/agents/plugins/copilot-cli/copilot-cli.models.js +195 -0
  45. package/dist/agents/plugins/copilot-cli/copilot-cli.models.js.map +1 -0
  46. package/dist/agents/plugins/copilot-cli/copilot-cli.paths.d.ts +11 -0
  47. package/dist/agents/plugins/copilot-cli/copilot-cli.paths.d.ts.map +1 -0
  48. package/dist/agents/plugins/copilot-cli/copilot-cli.paths.js +21 -0
  49. package/dist/agents/plugins/copilot-cli/copilot-cli.paths.js.map +1 -0
  50. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts +14 -0
  51. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts.map +1 -0
  52. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js +263 -0
  53. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js.map +1 -0
  54. package/dist/agents/plugins/copilot-cli/copilot-cli.session.d.ts +43 -0
  55. package/dist/agents/plugins/copilot-cli/copilot-cli.session.d.ts.map +1 -0
  56. package/dist/agents/plugins/copilot-cli/copilot-cli.session.js +343 -0
  57. package/dist/agents/plugins/copilot-cli/copilot-cli.session.js.map +1 -0
  58. package/dist/agents/plugins/copilot-cli/copilot-cli.storage-utils.d.ts +10 -0
  59. package/dist/agents/plugins/copilot-cli/copilot-cli.storage-utils.d.ts.map +1 -0
  60. package/dist/agents/plugins/copilot-cli/copilot-cli.storage-utils.js +41 -0
  61. package/dist/agents/plugins/copilot-cli/copilot-cli.storage-utils.js.map +1 -0
  62. package/dist/agents/plugins/copilot-cli/copilot-cli.usage.d.ts +37 -0
  63. package/dist/agents/plugins/copilot-cli/copilot-cli.usage.d.ts.map +1 -0
  64. package/dist/agents/plugins/copilot-cli/copilot-cli.usage.js +96 -0
  65. package/dist/agents/plugins/copilot-cli/copilot-cli.usage.js.map +1 -0
  66. package/dist/agents/plugins/copilot-cli/copilot-cli.workspace.d.ts +17 -0
  67. package/dist/agents/plugins/copilot-cli/copilot-cli.workspace.d.ts.map +1 -0
  68. package/dist/agents/plugins/copilot-cli/copilot-cli.workspace.js +58 -0
  69. package/dist/agents/plugins/copilot-cli/copilot-cli.workspace.js.map +1 -0
  70. package/dist/agents/plugins/copilot-cli/index.d.ts +3 -0
  71. package/dist/agents/plugins/copilot-cli/index.d.ts.map +1 -0
  72. package/dist/agents/plugins/copilot-cli/index.js +3 -0
  73. package/dist/agents/plugins/copilot-cli/index.js.map +1 -0
  74. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts +18 -0
  75. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts.map +1 -0
  76. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js +313 -0
  77. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js.map +1 -0
  78. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.metrics-processor.d.ts +16 -0
  79. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.metrics-processor.d.ts.map +1 -0
  80. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.metrics-processor.js +22 -0
  81. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.metrics-processor.js.map +1 -0
  82. package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts +12 -0
  83. package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts.map +1 -0
  84. package/dist/agents/plugins/pi/__tests__/home-redirect.js +27 -0
  85. package/dist/agents/plugins/pi/__tests__/home-redirect.js.map +1 -0
  86. package/dist/agents/plugins/pi/extension/README.md +68 -0
  87. package/dist/agents/plugins/pi/extension/index.js +161 -0
  88. package/dist/agents/plugins/pi/extension/package.json +8 -0
  89. package/dist/agents/plugins/pi/index.d.ts +3 -0
  90. package/dist/agents/plugins/pi/index.d.ts.map +1 -0
  91. package/dist/agents/plugins/pi/index.js +3 -0
  92. package/dist/agents/plugins/pi/index.js.map +1 -0
  93. package/dist/agents/plugins/pi/pi.extension.d.ts +60 -0
  94. package/dist/agents/plugins/pi/pi.extension.d.ts.map +1 -0
  95. package/dist/agents/plugins/pi/pi.extension.js +201 -0
  96. package/dist/agents/plugins/pi/pi.extension.js.map +1 -0
  97. package/dist/agents/plugins/pi/pi.incremental-sync.d.ts +63 -0
  98. package/dist/agents/plugins/pi/pi.incremental-sync.d.ts.map +1 -0
  99. package/dist/agents/plugins/pi/pi.incremental-sync.js +266 -0
  100. package/dist/agents/plugins/pi/pi.incremental-sync.js.map +1 -0
  101. package/dist/agents/plugins/pi/pi.models.d.ts +20 -0
  102. package/dist/agents/plugins/pi/pi.models.d.ts.map +1 -0
  103. package/dist/agents/plugins/pi/pi.models.js +201 -0
  104. package/dist/agents/plugins/pi/pi.models.js.map +1 -0
  105. package/dist/agents/plugins/pi/pi.packages.d.ts +11 -0
  106. package/dist/agents/plugins/pi/pi.packages.d.ts.map +1 -0
  107. package/dist/agents/plugins/pi/pi.packages.js +35 -0
  108. package/dist/agents/plugins/pi/pi.packages.js.map +1 -0
  109. package/dist/agents/plugins/pi/pi.paths.d.ts +37 -0
  110. package/dist/agents/plugins/pi/pi.paths.d.ts.map +1 -0
  111. package/dist/agents/plugins/pi/pi.paths.js +146 -0
  112. package/dist/agents/plugins/pi/pi.paths.js.map +1 -0
  113. package/dist/agents/plugins/pi/pi.plugin.d.ts +30 -0
  114. package/dist/agents/plugins/pi/pi.plugin.d.ts.map +1 -0
  115. package/dist/agents/plugins/pi/pi.plugin.js +453 -0
  116. package/dist/agents/plugins/pi/pi.plugin.js.map +1 -0
  117. package/dist/agents/plugins/pi/pi.session.d.ts +114 -0
  118. package/dist/agents/plugins/pi/pi.session.d.ts.map +1 -0
  119. package/dist/agents/plugins/pi/pi.session.js +388 -0
  120. package/dist/agents/plugins/pi/pi.session.js.map +1 -0
  121. package/dist/agents/plugins/pi/pi.setup.d.ts +2 -0
  122. package/dist/agents/plugins/pi/pi.setup.d.ts.map +1 -0
  123. package/dist/agents/plugins/pi/pi.setup.js +33 -0
  124. package/dist/agents/plugins/pi/pi.setup.js.map +1 -0
  125. package/dist/agents/plugins/pi/pi.types.d.ts +143 -0
  126. package/dist/agents/plugins/pi/pi.types.d.ts.map +1 -0
  127. package/dist/agents/plugins/pi/pi.types.js +74 -0
  128. package/dist/agents/plugins/pi/pi.types.js.map +1 -0
  129. package/dist/agents/plugins/pi/session/pi-file-operations.d.ts +17 -0
  130. package/dist/agents/plugins/pi/session/pi-file-operations.d.ts.map +1 -0
  131. package/dist/agents/plugins/pi/session/pi-file-operations.js +98 -0
  132. package/dist/agents/plugins/pi/session/pi-file-operations.js.map +1 -0
  133. package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts +52 -0
  134. package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts.map +1 -0
  135. package/dist/agents/plugins/pi/session/pi-named-invocations.js +189 -0
  136. package/dist/agents/plugins/pi/session/pi-named-invocations.js.map +1 -0
  137. package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts +14 -0
  138. package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts.map +1 -0
  139. package/dist/agents/plugins/pi/session/pi-user-prompt.js +51 -0
  140. package/dist/agents/plugins/pi/session/pi-user-prompt.js.map +1 -0
  141. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts +52 -0
  142. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts.map +1 -0
  143. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js +716 -0
  144. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js.map +1 -0
  145. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts +104 -0
  146. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts.map +1 -0
  147. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js +595 -0
  148. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js.map +1 -0
  149. package/dist/agents/registry.d.ts +20 -0
  150. package/dist/agents/registry.d.ts.map +1 -1
  151. package/dist/agents/registry.js +29 -2
  152. package/dist/agents/registry.js.map +1 -1
  153. package/dist/cli/commands/analytics/agent-labels.d.ts +3 -0
  154. package/dist/cli/commands/analytics/agent-labels.d.ts.map +1 -0
  155. package/dist/cli/commands/analytics/agent-labels.js +20 -0
  156. package/dist/cli/commands/analytics/agent-labels.js.map +1 -0
  157. package/dist/cli/commands/analytics/cost/cost-enricher.d.ts.map +1 -1
  158. package/dist/cli/commands/analytics/cost/cost-enricher.js +12 -0
  159. package/dist/cli/commands/analytics/cost/cost-enricher.js.map +1 -1
  160. package/dist/cli/commands/analytics/cost/types.d.ts +10 -0
  161. package/dist/cli/commands/analytics/cost/types.d.ts.map +1 -1
  162. package/dist/cli/commands/analytics/cost/usage-readers.d.ts +24 -0
  163. package/dist/cli/commands/analytics/cost/usage-readers.d.ts.map +1 -1
  164. package/dist/cli/commands/analytics/cost/usage-readers.js +253 -54
  165. package/dist/cli/commands/analytics/cost/usage-readers.js.map +1 -1
  166. package/dist/cli/commands/analytics/formatter.d.ts.map +1 -1
  167. package/dist/cli/commands/analytics/formatter.js +10 -2
  168. package/dist/cli/commands/analytics/formatter.js.map +1 -1
  169. package/dist/cli/commands/analytics/index.d.ts.map +1 -1
  170. package/dist/cli/commands/analytics/index.js +22 -0
  171. package/dist/cli/commands/analytics/index.js.map +1 -1
  172. package/dist/cli/commands/analytics/native-loader.d.ts +21 -4
  173. package/dist/cli/commands/analytics/native-loader.d.ts.map +1 -1
  174. package/dist/cli/commands/analytics/native-loader.js +267 -88
  175. package/dist/cli/commands/analytics/native-loader.js.map +1 -1
  176. package/dist/cli/commands/analytics/report/client/app.js +77 -15
  177. package/dist/cli/commands/analytics/report/payload-builder.d.ts.map +1 -1
  178. package/dist/cli/commands/analytics/report/payload-builder.js +32 -2
  179. package/dist/cli/commands/analytics/report/payload-builder.js.map +1 -1
  180. package/dist/cli/commands/analytics/report/types.d.ts +11 -0
  181. package/dist/cli/commands/analytics/report/types.d.ts.map +1 -1
  182. package/dist/cli/commands/hook.d.ts.map +1 -1
  183. package/dist/cli/commands/hook.js +71 -29
  184. package/dist/cli/commands/hook.js.map +1 -1
  185. package/dist/cli/commands/install.d.ts.map +1 -1
  186. package/dist/cli/commands/install.js +9 -7
  187. package/dist/cli/commands/install.js.map +1 -1
  188. package/dist/cli/commands/list.d.ts.map +1 -1
  189. package/dist/cli/commands/list.js +4 -2
  190. package/dist/cli/commands/list.js.map +1 -1
  191. package/dist/cli/commands/setup.d.ts +3 -1
  192. package/dist/cli/commands/setup.d.ts.map +1 -1
  193. package/dist/cli/commands/setup.js +87 -63
  194. package/dist/cli/commands/setup.js.map +1 -1
  195. package/dist/cli/commands/uninstall.d.ts.map +1 -1
  196. package/dist/cli/commands/uninstall.js +6 -4
  197. package/dist/cli/commands/uninstall.js.map +1 -1
  198. package/dist/cli/commands/update.d.ts.map +1 -1
  199. package/dist/cli/commands/update.js +7 -5
  200. package/dist/cli/commands/update.js.map +1 -1
  201. package/dist/cli/first-time.d.ts.map +1 -1
  202. package/dist/cli/first-time.js +10 -9
  203. package/dist/cli/first-time.js.map +1 -1
  204. package/dist/providers/core/auth-validation.d.ts +7 -2
  205. package/dist/providers/core/auth-validation.d.ts.map +1 -1
  206. package/dist/providers/core/auth-validation.js +11 -5
  207. package/dist/providers/core/auth-validation.js.map +1 -1
  208. package/dist/providers/core/types.d.ts +16 -0
  209. package/dist/providers/core/types.d.ts.map +1 -1
  210. package/dist/providers/core/types.js.map +1 -1
  211. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts +8 -3
  212. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts.map +1 -1
  213. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js +46 -11
  214. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js.map +1 -1
  215. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts +23 -13
  216. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts.map +1 -1
  217. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js +75 -18
  218. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js.map +1 -1
  219. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts +21 -0
  220. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts.map +1 -0
  221. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js +133 -0
  222. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js.map +1 -0
  223. package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js +1 -1
  224. package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js.map +1 -1
  225. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +2 -1
  226. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  227. package/dist/providers/plugins/sso/proxy/plugins/index.js +4 -2
  228. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  229. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts +11 -0
  230. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts.map +1 -1
  231. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts +2 -0
  232. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts.map +1 -1
  233. package/dist/providers/plugins/sso/proxy/sso.proxy.js +37 -1
  234. package/dist/providers/plugins/sso/proxy/sso.proxy.js.map +1 -1
  235. package/dist/providers/plugins/sso/session/SessionSyncer.d.ts.map +1 -1
  236. package/dist/providers/plugins/sso/session/SessionSyncer.js +13 -0
  237. package/dist/providers/plugins/sso/session/SessionSyncer.js.map +1 -1
  238. package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js +6 -0
  239. package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js.map +1 -1
  240. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts +0 -6
  241. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts.map +1 -1
  242. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js +28 -19
  243. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js.map +1 -1
  244. package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
  245. package/dist/providers/plugins/sso/sso.setup-steps.js +39 -22
  246. package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
  247. package/dist/utils/interactive.d.ts +14 -0
  248. package/dist/utils/interactive.d.ts.map +1 -0
  249. package/dist/utils/interactive.js +16 -0
  250. package/dist/utils/interactive.js.map +1 -0
  251. package/package.json +6 -5
  252. package/scripts/copy-plugins.js +6 -0
  253. package/scripts/release.sh +54 -0
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Best-effort TypeScript shapes for Pi session JSONL entries.
3
+ *
4
+ * Based on the shipped Pi CLI's v3 session format
5
+ * (packages/coding-agent/src/core/session-manager.ts), not the v4 harness format.
6
+ * Kept local so the plugin does not depend on the upstream Pi packages.
7
+ */
8
+ export function isPiMessageEntry(entry) {
9
+ return (entry !== null &&
10
+ typeof entry === 'object' &&
11
+ entry.type === 'message' &&
12
+ 'message' in entry &&
13
+ entry.message !== null &&
14
+ typeof entry.message === 'object');
15
+ }
16
+ export function isPiUserMessage(message) {
17
+ return message.role === 'user';
18
+ }
19
+ export function isPiAssistantMessage(message) {
20
+ return message.role === 'assistant';
21
+ }
22
+ export function isPiToolResultMessage(message) {
23
+ return message.role === 'toolResult';
24
+ }
25
+ export function isPiBashExecutionMessage(message) {
26
+ return message.role === 'bashExecution';
27
+ }
28
+ export function isPiModelChangeEntry(entry) {
29
+ return (entry !== null &&
30
+ typeof entry === 'object' &&
31
+ entry.type === 'model_change' &&
32
+ typeof entry.modelId === 'string' &&
33
+ entry.modelId.length > 0);
34
+ }
35
+ /**
36
+ * Normalize the tool calls carried by an assistant message.
37
+ *
38
+ * Shared by the metrics processor and the named-invocation extractor so both tolerate
39
+ * the same two serializations: the flat `{type:'toolCall', id, name}` the Pi runtime
40
+ * writes, and a defensive `{type:'toolCall', toolCall:{...}}` wrapper in case a Pi
41
+ * version or provider nests it.
42
+ */
43
+ export function extractPiToolCalls(message) {
44
+ if (!Array.isArray(message.content)) {
45
+ return [];
46
+ }
47
+ return message.content
48
+ .map((part) => {
49
+ if (typeof part !== 'object' || part === null) {
50
+ return undefined;
51
+ }
52
+ const flat = part;
53
+ if (flat.type === 'toolCall' && typeof flat.id === 'string' && typeof flat.name === 'string') {
54
+ return flat;
55
+ }
56
+ const nested = part.toolCall;
57
+ if (nested && typeof nested.id === 'string' && typeof nested.name === 'string') {
58
+ return nested;
59
+ }
60
+ return undefined;
61
+ })
62
+ .filter((toolCall) => toolCall !== undefined);
63
+ }
64
+ export function isPiSessionHeader(value) {
65
+ if (!value || typeof value !== 'object')
66
+ return false;
67
+ const header = value;
68
+ return (header.type === 'session' &&
69
+ typeof header.id === 'string' &&
70
+ header.id.length > 0 &&
71
+ typeof header.timestamp === 'string' &&
72
+ typeof header.cwd === 'string');
73
+ }
74
+ //# sourceMappingURL=pi.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.types.js","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgJH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,CACL,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,IAAI,KAAK,SAAS;QACxB,SAAS,IAAI,KAAK;QAClB,KAAK,CAAC,OAAO,KAAK,IAAI;QACtB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAuB;IACrD,OAAO,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAuB;IAC1D,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAuB;IAC3D,OAAO,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAuB;IAC9D,OAAO,OAAO,CAAC,IAAI,KAAK,eAAe,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,CACL,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,IAAI,KAAK,cAAc;QAC7B,OAAQ,KAA4B,CAAC,OAAO,KAAK,QAAQ;QACxD,KAA4B,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CACjD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA2B;IAC5D,IAA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C;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Map Pi tool calls/results to CodeMie file-operation records.
3
+ */
4
+ import type { FileOperation } from '../../../core/metrics/types.js';
5
+ /**
6
+ * Count added/removed lines in a unified diff string.
7
+ */
8
+ export declare function countPiDiffLines(patch: unknown): {
9
+ linesAdded: number;
10
+ linesRemoved: number;
11
+ };
12
+ /**
13
+ * Build a file-operation record for a Pi tool call, or undefined if the tool
14
+ * is not a tracked file/search tool.
15
+ */
16
+ export declare function extractPiFileOperation(toolName: string, toolArguments?: Record<string, unknown>, toolResultDetails?: Record<string, unknown>): FileOperation | undefined;
17
+ //# sourceMappingURL=pi-file-operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-file-operations.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-file-operations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAqB,MAAM,gCAAgC,CAAC;AA4BvF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAgB7F;AAYD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC1C,aAAa,GAAG,SAAS,CAsC3B"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Map Pi tool calls/results to CodeMie file-operation records.
3
+ */
4
+ import { extractFormat, detectLanguage } from '../../../../utils/file-operations.js';
5
+ import { logger } from '../../../../utils/logger.js';
6
+ // Pi's closed tool registry is read | bash | edit | write | grep | find | ls
7
+ // (packages/coding-agent/src/core/tools/index.ts). `find` is Pi's glob-by-filename
8
+ // tool. `bash` is intentionally absent: it mutates files arbitrarily (`sed -i`,
9
+ // `>`, `mv`, `git apply`, etc.) and no reliable file-effect signal is persisted.
10
+ // `write` creates OR overwrites; the result does not record which occurred.
11
+ //
12
+ // Tool names are matched case-sensitively: extension tools may register arbitrary
13
+ // names, and lowercasing would misclassify an extension named `Write` as the
14
+ // built-in write tool.
15
+ //
16
+ // There is deliberately no 'delete' mapping, so `files_deleted` stays at 0. That is
17
+ // parity, not a gap: Pi ships no delete tool, and Claude's own TOOL_TYPE_MAP
18
+ // (claude/session/claude-file-operation.ts) has no delete entry either. Inferring
19
+ // deletions from `rm` inside a bash command would report a number Claude never reports
20
+ // and would be wrong whenever the command fails, is conditional, or is a dry run.
21
+ const TOOL_TYPE_MAP = {
22
+ read: 'read',
23
+ edit: 'edit',
24
+ write: 'write',
25
+ grep: 'grep',
26
+ ls: 'read',
27
+ find: 'glob',
28
+ };
29
+ /**
30
+ * Count added/removed lines in a unified diff string.
31
+ */
32
+ export function countPiDiffLines(patch) {
33
+ if (typeof patch !== 'string' || patch.length === 0) {
34
+ return { linesAdded: 0, linesRemoved: 0 };
35
+ }
36
+ let linesAdded = 0;
37
+ let linesRemoved = 0;
38
+ for (const line of patch.split('\n')) {
39
+ if (line.startsWith('@@'))
40
+ continue;
41
+ if (line.startsWith('+++ ') || line.startsWith('--- '))
42
+ continue;
43
+ if (line.startsWith('+'))
44
+ linesAdded++;
45
+ else if (line.startsWith('-'))
46
+ linesRemoved++;
47
+ }
48
+ return { linesAdded, linesRemoved };
49
+ }
50
+ function extractPath(args, details) {
51
+ const fromArgs = args?.path ?? args?.filePath ?? args?.file_path;
52
+ if (typeof fromArgs === 'string')
53
+ return fromArgs;
54
+ const fromDetails = details?.path ?? details?.filePath ?? details?.file_path;
55
+ if (typeof fromDetails === 'string')
56
+ return fromDetails;
57
+ return undefined;
58
+ }
59
+ /**
60
+ * Build a file-operation record for a Pi tool call, or undefined if the tool
61
+ * is not a tracked file/search tool.
62
+ */
63
+ export function extractPiFileOperation(toolName, toolArguments, toolResultDetails) {
64
+ const type = TOOL_TYPE_MAP[toolName];
65
+ if (!type) {
66
+ logger.debug(`[pi-file-ops] No file-operation mapping for tool: ${toolName}`);
67
+ return undefined;
68
+ }
69
+ const operation = { type };
70
+ const filePath = extractPath(toolArguments, toolResultDetails);
71
+ if (filePath) {
72
+ operation.path = filePath;
73
+ operation.format = extractFormat(filePath);
74
+ operation.language = detectLanguage(filePath);
75
+ }
76
+ if (typeof toolArguments?.pattern === 'string') {
77
+ operation.pattern = toolArguments.pattern;
78
+ }
79
+ if (toolName === 'write') {
80
+ const content = toolArguments?.content;
81
+ if (typeof content === 'string' && content.length > 0) {
82
+ // Strip a single trailing newline so newline-terminated source files are
83
+ // not over-counted by one.
84
+ const normalized = content.endsWith('\n') ? content.slice(0, -1) : content;
85
+ operation.linesAdded = normalized.split('\n').length;
86
+ }
87
+ }
88
+ if (toolName === 'edit') {
89
+ const patch = toolResultDetails?.diff ?? toolResultDetails?.patch;
90
+ const { linesAdded, linesRemoved } = countPiDiffLines(patch);
91
+ if (linesAdded > 0)
92
+ operation.linesAdded = linesAdded;
93
+ if (linesRemoved > 0)
94
+ operation.linesRemoved = linesRemoved;
95
+ }
96
+ return operation;
97
+ }
98
+ //# sourceMappingURL=pi-file-operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-file-operations.js","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-file-operations.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,6EAA6E;AAC7E,mFAAmF;AACnF,gFAAgF;AAChF,iFAAiF;AACjF,4EAA4E;AAC5E,EAAE;AACF,kFAAkF;AAClF,6EAA6E;AAC7E,uBAAuB;AACvB,EAAE;AACF,oFAAoF;AACpF,6EAA6E;AAC7E,kFAAkF;AAClF,uFAAuF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C,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QACvD,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,iBAAiB,EAAE,IAAI,IAAI,iBAAiB,EAAE,KAAK,CAAC;QAClE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC7D,IAAI,UAAU,GAAG,CAAC;YAAE,SAAS,CAAC,UAAU,GAAG,UAAU,CAAC;QACtD,IAAI,YAAY,GAAG,CAAC;YAAE,SAAS,CAAC,YAAY,GAAG,YAAY,CAAC;IAC9D,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Shared Pi named-invocation extraction.
3
+ *
4
+ * Pulls the *names* of invoked skills and subagents out of Pi session JSONL entries, so
5
+ * the analytics report shows the same per-name breakdown Claude and Codex already do.
6
+ *
7
+ * - Skills: the `<skill name="..." location="...">` wrapper Pi prepends to the user
8
+ * message when a `/skill:<name>` command expands (upstream
9
+ * `core/agent-session.ts` builds it, and parses it back with the same shape).
10
+ * - Agents: an assistant `toolCall` named `subagent`, from the `pi-subagents` package
11
+ * this plugin installs. The child's name is `arguments.agent`.
12
+ * - Commands: always empty here. Pi expands a prompt template into plain user text before
13
+ * persisting it, so `/review` never reaches the JSONL and no regex over the
14
+ * transcript can recover it. Those counts come from the run ledger, which the
15
+ * CodeMie extension records from inside Pi at input time.
16
+ *
17
+ * @see ../pi.extension.ts — PiRunLedger.commandInvocations
18
+ */
19
+ import type { NamedInvocationCounts } from '../../claude/session/claude-named-invocations.js';
20
+ export type { NamedInvocationCounts };
21
+ export interface PiSkillWrapper {
22
+ /** Skill name from the wrapper, or undefined when the text carries no wrapper. */
23
+ name?: string;
24
+ /** The prompt the user typed after the wrapper, or the original text when there was none. */
25
+ rest: string;
26
+ }
27
+ /**
28
+ * Split Pi's `<skill>` wrapper off a user text block.
29
+ *
30
+ * Single source of truth for the wrapper shape: the metrics processor consumes `rest`
31
+ * so the skill body is not reported as a user prompt, and the extractor below consumes
32
+ * `name`.
33
+ *
34
+ * The closing line is searched for from the END of the text, because the body between the
35
+ * wrapper's tags is a file the user wrote and may contain `</skill>` lines of its own — a
36
+ * skill documenting Pi's own format does. Everything after the LAST closing line, on the
37
+ * other hand, can only be the arguments the user typed: the real closer always leaves a
38
+ * well-formed tail behind it, so no closer after it exists to be picked instead.
39
+ *
40
+ * Anything else fails closed with no name and no text. `rest` leaves the machine — it is
41
+ * uploaded as the user's prompt and titles the analytics session — so a wrapper this parser
42
+ * cannot read unambiguously must cost a title rather than a private file's contents.
43
+ */
44
+ export declare function parseSkillWrapper(text: string): PiSkillWrapper;
45
+ /**
46
+ * Extract skill and agent name counts from Pi session entries.
47
+ *
48
+ * Safe against missing or malformed fields — anything that is not a recognized shape is
49
+ * skipped. `commandInvocations` is always empty; see the module comment.
50
+ */
51
+ export declare function extractPiNamedInvocations(entries: readonly unknown[]): NamedInvocationCounts;
52
+ //# sourceMappingURL=pi-named-invocations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-named-invocations.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-named-invocations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;AAU9F,YAAY,EAAE,qBAAqB,EAAE,CAAC;AA8CtC,MAAM,WAAW,cAAc;IAC7B,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CA8B9D;AA4DD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,qBAAqB,CA8B5F"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Shared Pi named-invocation extraction.
3
+ *
4
+ * Pulls the *names* of invoked skills and subagents out of Pi session JSONL entries, so
5
+ * the analytics report shows the same per-name breakdown Claude and Codex already do.
6
+ *
7
+ * - Skills: the `<skill name="..." location="...">` wrapper Pi prepends to the user
8
+ * message when a `/skill:<name>` command expands (upstream
9
+ * `core/agent-session.ts` builds it, and parses it back with the same shape).
10
+ * - Agents: an assistant `toolCall` named `subagent`, from the `pi-subagents` package
11
+ * this plugin installs. The child's name is `arguments.agent`.
12
+ * - Commands: always empty here. Pi expands a prompt template into plain user text before
13
+ * persisting it, so `/review` never reaches the JSONL and no regex over the
14
+ * transcript can recover it. Those counts come from the run ledger, which the
15
+ * CodeMie extension records from inside Pi at input time.
16
+ *
17
+ * @see ../pi.extension.ts — PiRunLedger.commandInvocations
18
+ */
19
+ import { logger } from '../../../../utils/logger.js';
20
+ import { extractPiToolCalls, isPiAssistantMessage, isPiMessageEntry, isPiUserMessage, } from '../pi.types.js';
21
+ /** Name of the tool `pi-subagents` registers for delegating to a child agent. */
22
+ const SUBAGENT_TOOL = 'subagent';
23
+ /**
24
+ * The opening of Pi's skill wrapper, which only Pi itself writes (`_expandSkillCommand` in
25
+ * `core/agent-session.ts`). Group 1 is the skill name.
26
+ *
27
+ * Matching it is also what makes {@link parseSkillWrapper} fail closed: once the opening is
28
+ * there the text is a skill file's body, so a wrapper this parser cannot finish reading is
29
+ * dropped. That costs one prompt title; returning it would upload a private file.
30
+ */
31
+ const SKILL_WRAPPER_OPENING = /^<skill name="([^"]+)" location="[^"]+">\n/;
32
+ /**
33
+ * The line that closes the wrapper. Pi writes it on a line of its own, so the leading
34
+ * newline is part of the delimiter.
35
+ */
36
+ const SKILL_WRAPPER_CLOSING = '\n</skill>';
37
+ /**
38
+ * `agent: "<name>"` inside a `workflowScript`. The script is an opaque JavaScript string
39
+ * (`await runs.run(key, { agent, task })`), not a structured step list, so this is the
40
+ * only handle on the children it launches. It counts one invocation per launch site:
41
+ * a script that loops over the same site undercounts, and a computed agent name is
42
+ * missed entirely. Both are preferable to attributing a workflow to no agent at all.
43
+ */
44
+ const WORKFLOW_AGENT = /\bagent\s*:\s*(['"`])([^'"`\n]+)\1/g;
45
+ /**
46
+ * The one `action` that launches a child rather than managing a record.
47
+ *
48
+ * `pi-subagents` rejects a `schedule.create` that does not name exactly one target —
49
+ * `agent` (with an optional `task`) or a `workflowScript` — and arms it to run later
50
+ * (`runs/background/scheduled-runs.ts`, `sanitizeTarget`). The launch is counted here, at
51
+ * the call that asked for it, because the firings themselves happen outside any CodeMie
52
+ * session and would otherwise be attributed to nothing. `schedule.run`/`schedule.run-due`
53
+ * stay management: they address an existing schedule by id and carry no agent name.
54
+ */
55
+ const DEFERRED_LAUNCH_ACTION = 'schedule.create';
56
+ function bump(map, key) {
57
+ map[key] = (map[key] || 0) + 1;
58
+ }
59
+ /**
60
+ * Split Pi's `<skill>` wrapper off a user text block.
61
+ *
62
+ * Single source of truth for the wrapper shape: the metrics processor consumes `rest`
63
+ * so the skill body is not reported as a user prompt, and the extractor below consumes
64
+ * `name`.
65
+ *
66
+ * The closing line is searched for from the END of the text, because the body between the
67
+ * wrapper's tags is a file the user wrote and may contain `</skill>` lines of its own — a
68
+ * skill documenting Pi's own format does. Everything after the LAST closing line, on the
69
+ * other hand, can only be the arguments the user typed: the real closer always leaves a
70
+ * well-formed tail behind it, so no closer after it exists to be picked instead.
71
+ *
72
+ * Anything else fails closed with no name and no text. `rest` leaves the machine — it is
73
+ * uploaded as the user's prompt and titles the analytics session — so a wrapper this parser
74
+ * cannot read unambiguously must cost a title rather than a private file's contents.
75
+ */
76
+ export function parseSkillWrapper(text) {
77
+ const opening = SKILL_WRAPPER_OPENING.exec(text);
78
+ if (!opening) {
79
+ return { rest: text };
80
+ }
81
+ // The opening's own trailing newline can double as the closing line's leading one, for a
82
+ // wrapper around an empty body. Nothing before that is part of the wrapper.
83
+ const earliestClosing = opening[0].length - 1;
84
+ for (let closing = text.lastIndexOf(SKILL_WRAPPER_CLOSING); closing >= earliestClosing; closing = text.lastIndexOf(SKILL_WRAPPER_CLOSING, closing - 1)) {
85
+ // Upstream appends `\n\n<args>` only when the `/skill:<name>` invocation carried
86
+ // arguments, so a well-formed tail is either nothing at all or exactly that.
87
+ const tail = text.slice(closing + SKILL_WRAPPER_CLOSING.length);
88
+ if (tail === '') {
89
+ return { name: opening[1], rest: '' };
90
+ }
91
+ const args = tail.startsWith('\n\n') ? tail.slice(2).trim() : '';
92
+ if (args) {
93
+ return { name: opening[1], rest: args };
94
+ }
95
+ }
96
+ // Name only: the body is exactly what must not be logged. Without this line a change to
97
+ // Pi's wrapper would zero prompts and skill counts at once, silently.
98
+ logger.debug('[pi-skills] Unreadable skill wrapper; dropping the text', { skill: opening[1] });
99
+ return { rest: '' };
100
+ }
101
+ /** Every text block carried by a user message, whatever content shape Pi used. */
102
+ function userTextBlocks(message) {
103
+ if (typeof message.content === 'string') {
104
+ return [message.content];
105
+ }
106
+ if (!Array.isArray(message.content)) {
107
+ return [];
108
+ }
109
+ const texts = [];
110
+ for (const part of message.content) {
111
+ if (typeof part !== 'object' || part === null)
112
+ continue;
113
+ const typed = part;
114
+ if (typed.type === 'text' && typeof typed.text === 'string') {
115
+ texts.push(typed.text);
116
+ }
117
+ }
118
+ return texts;
119
+ }
120
+ /**
121
+ * Child agent names launched by one `subagent` tool call.
122
+ *
123
+ * A call carrying `action` is management or control (`status`, `stop`, `create`, ...);
124
+ * its `agent` names the record being managed, not a child being run, so it counts
125
+ * nothing. {@link DEFERRED_LAUNCH_ACTION} is the exception.
126
+ */
127
+ function subagentNames(args) {
128
+ if (!args || typeof args !== 'object') {
129
+ return [];
130
+ }
131
+ if (typeof args.action === 'string') {
132
+ const action = args.action.trim();
133
+ if (action && action !== DEFERRED_LAUNCH_ACTION) {
134
+ return [];
135
+ }
136
+ }
137
+ const names = [];
138
+ const single = args.agent;
139
+ if (typeof single === 'string' && single.trim()) {
140
+ names.push(single.trim());
141
+ }
142
+ const script = args.workflowScript;
143
+ if (typeof script === 'string') {
144
+ WORKFLOW_AGENT.lastIndex = 0;
145
+ let match;
146
+ while ((match = WORKFLOW_AGENT.exec(script)) !== null) {
147
+ const name = match[2].trim();
148
+ if (name)
149
+ names.push(name);
150
+ }
151
+ }
152
+ return names;
153
+ }
154
+ /**
155
+ * Extract skill and agent name counts from Pi session entries.
156
+ *
157
+ * Safe against missing or malformed fields — anything that is not a recognized shape is
158
+ * skipped. `commandInvocations` is always empty; see the module comment.
159
+ */
160
+ export function extractPiNamedInvocations(entries) {
161
+ const skillInvocations = {};
162
+ const agentInvocations = {};
163
+ for (const raw of entries) {
164
+ const entry = raw;
165
+ if (!isPiMessageEntry(entry)) {
166
+ continue;
167
+ }
168
+ const message = entry.message;
169
+ if (isPiUserMessage(message)) {
170
+ for (const text of userTextBlocks(message)) {
171
+ const { name } = parseSkillWrapper(text);
172
+ if (name)
173
+ bump(skillInvocations, name);
174
+ }
175
+ continue;
176
+ }
177
+ if (isPiAssistantMessage(message)) {
178
+ for (const toolCall of extractPiToolCalls(message)) {
179
+ if (toolCall.name !== SUBAGENT_TOOL)
180
+ continue;
181
+ for (const agent of subagentNames(toolCall.arguments)) {
182
+ bump(agentInvocations, agent);
183
+ }
184
+ }
185
+ }
186
+ }
187
+ return { skillInvocations, agentInvocations, commandInvocations: {} };
188
+ }
189
+ //# sourceMappingURL=pi-named-invocations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-named-invocations.js","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-named-invocations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAGhB,MAAM,g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AAI,OAAO,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,GAAc,CAAC;QAC7B,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,SAAS;QACX,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAE9B,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBACzC,IAAI,IAAI;oBAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,KAAK,MAAM,QAAQ,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnD,IAAI,QAAQ,CAAC,IAAI,KAAK,aAAa;oBAAE,SAAS;gBAC9C,KAAK,MAAM,KAAK,IAAI,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;oBACtD,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,EAAE,EAAE,CAAC;AACxE,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Extract the first real user prompt from Pi v3 session entries.
3
+ *
4
+ * A `/skill:<name>` invocation reaches the transcript as an ordinary user message whose text
5
+ * begins with Pi's literal `<skill …>…</skill>` block, followed by the prompt the user actually
6
+ * typed. Left in place that block becomes the session title in the report, so it is stripped
7
+ * via {@link parseSkillWrapper} — the single source of truth for the wrapper shape.
8
+ */
9
+ /**
10
+ * First user prompt in transcript order that still carries text once the skill wrapper is
11
+ * stripped. A message that is nothing but a skill block contributes no prompt and is skipped.
12
+ */
13
+ export declare function firstPiUserText(entries: readonly unknown[]): string | undefined;
14
+ //# sourceMappingURL=pi-user-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-user-prompt.d.ts","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-user-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqCH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,CAY/E"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Extract the first real user prompt from Pi v3 session entries.
3
+ *
4
+ * A `/skill:<name>` invocation reaches the transcript as an ordinary user message whose text
5
+ * begins with Pi's literal `<skill …>…</skill>` block, followed by the prompt the user actually
6
+ * typed. Left in place that block becomes the session title in the report, so it is stripped
7
+ * via {@link parseSkillWrapper} — the single source of truth for the wrapper shape.
8
+ */
9
+ import { parseSkillWrapper } from './pi-named-invocations.js';
10
+ /** Concatenated text of a Pi user message's content, skill wrapper stripped; undefined when empty. */
11
+ function piUserText(content) {
12
+ if (typeof content === 'string') {
13
+ return parseSkillWrapper(content).rest.trim() || undefined;
14
+ }
15
+ if (!Array.isArray(content)) {
16
+ return undefined;
17
+ }
18
+ const texts = [];
19
+ for (const part of content) {
20
+ if (!part || typeof part !== 'object') {
21
+ continue;
22
+ }
23
+ const block = part;
24
+ if (block.type !== 'text' || typeof block.text !== 'string') {
25
+ continue;
26
+ }
27
+ const text = parseSkillWrapper(block.text).rest.trim();
28
+ if (text) {
29
+ texts.push(text);
30
+ }
31
+ }
32
+ return texts.length > 0 ? texts.join('\n') : undefined;
33
+ }
34
+ /**
35
+ * First user prompt in transcript order that still carries text once the skill wrapper is
36
+ * stripped. A message that is nothing but a skill block contributes no prompt and is skipped.
37
+ */
38
+ export function firstPiUserText(entries) {
39
+ for (const raw of entries) {
40
+ const entry = raw;
41
+ if (entry?.type !== 'message' || entry.message?.role !== 'user') {
42
+ continue;
43
+ }
44
+ const text = piUserText(entry.message.content);
45
+ if (text) {
46
+ return text;
47
+ }
48
+ }
49
+ return undefined;
50
+ }
51
+ //# sourceMappingURL=pi-user-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi-user-prompt.js","sourceRoot":"","sources":["../../../../../src/agents/plugins/pi/session/pi-user-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAU9D,sGAAsG;AACtG,SAAS,UAAU,CAAC,OAAgB;IAClC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC;IAC7D,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtC,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,IAAyC,CAAC;QACxD,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC5D,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACvD,IAAI,IAAI,EAAE,CAAC;YACT,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAA2B;IACzD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,GAAoB,CAAC;QACnC,IAAI,KAAK,EAAE,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;YAChE,SAAS;QACX,CAAC;QACD,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Pi Conversations Processor
3
+ *
4
+ * Turns Pi's v3 JSONL entry tree into incremental CodeMie conversation payloads so a Pi
5
+ * run shows up in the conversations UI the same way Claude, Codex, OpenCode and Gemini
6
+ * runs do.
7
+ *
8
+ * What survives the translation:
9
+ * - user prompts (with Pi's `<skill …>` wrapper stripped, and a wordless prompt described
10
+ * by what it did carry rather than dropped — see `describeUserPrompt`)
11
+ * - the last assistant text of a turn as the visible reply; earlier ones as thoughts
12
+ * - thinking blocks as reasoning thoughts
13
+ * - toolCall/toolResult pairs as Tool thoughts
14
+ * - `!`-style bash executions, unless the user marked them private (`!!`)
15
+ * - compaction and branch summaries as summary thoughts
16
+ *
17
+ * What deliberately does not: anything on an abandoned branch. A Pi session file is an
18
+ * append-only *tree*, so a `/rewind` or an edited message leaves the discarded exchange
19
+ * in the file forever; only the active branch is uploaded.
20
+ */
21
+ import type { SessionProcessor, ProcessingContext, ProcessingResult } from '../../../../../agents/core/session/BaseProcessor.js';
22
+ import type { ParsedSession } from '../../../../../agents/core/session/BaseSessionAdapter.js';
23
+ export declare class PiConversationsProcessor implements SessionProcessor {
24
+ readonly name = "pi-conversations";
25
+ readonly priority = 2;
26
+ shouldProcess(session: ParsedSession): boolean;
27
+ process(session: ParsedSession, _context: ProcessingContext): Promise<ProcessingResult>;
28
+ /**
29
+ * The file position this conversation's sync reached.
30
+ *
31
+ * Both the persisted session state and the queued payload file are shared by every
32
+ * transcript of the run, so a checkpoint only counts when its sentinel names *this*
33
+ * conversation — otherwise a `/new` transcript would inherit the previous one's position
34
+ * and silently skip its own opening turns.
35
+ *
36
+ * Only the position is taken from state. `lastSyncedHistoryIndex` deliberately is not:
37
+ * the sync processor computes it as a maximum over the payloads of *all* conversations
38
+ * in the session and the session store then keeps it monotonic, so it says nothing about
39
+ * where one conversation is. Turn numbering comes from the transcript instead
40
+ * (see `scanNextTurn`).
41
+ */
42
+ private resolveSyncedSourceIndex;
43
+ /**
44
+ * Queue one payload per complete turn past the checkpoint.
45
+ *
46
+ * Pi only fires SessionStart and SessionEnd, so a run's whole backlog arrives in a
47
+ * single call. Emitting one window per call — as the per-turn-hooked agents can
48
+ * afford to — would strand every turn but the first.
49
+ */
50
+ private appendTurnPayloads;
51
+ }
52
+ //# sourceMappingURL=pi.conversations-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.conversations-processor.d.ts","sourceRoot":"","sources":["../../../../../../src/agents/plugins/pi/session/processors/pi.conversations-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AACpH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AA6FjF,qBAAa,wBAAyB,YAAW,gBAAgB;IAC/D,QAAQ,CAAC,IAAI,sBAAmC;IAChD,QAAQ,CAAC,QAAQ,KAAK;IAEtB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;IAKxC,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsG7F;;;;;;;;;;;;;OAaG;YACW,wBAAwB;IAsBtC;;;;;;OAMG;YACW,kBAAkB;CAoGjC"}