@codemieai/code 0.12.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 (204) 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/session-origin-audit.d.ts +13 -0
  15. package/dist/agents/core/session/session-origin-audit.d.ts.map +1 -1
  16. package/dist/agents/core/session/session-origin-audit.js +34 -0
  17. package/dist/agents/core/session/session-origin-audit.js.map +1 -1
  18. package/dist/agents/core/session/stale-session-reconciliation.d.ts +42 -0
  19. package/dist/agents/core/session/stale-session-reconciliation.d.ts.map +1 -0
  20. package/dist/agents/core/session/stale-session-reconciliation.js +141 -0
  21. package/dist/agents/core/session/stale-session-reconciliation.js.map +1 -0
  22. package/dist/agents/core/session/types.d.ts +19 -0
  23. package/dist/agents/core/session/types.d.ts.map +1 -1
  24. package/dist/agents/core/session/types.js +17 -1
  25. package/dist/agents/core/session/types.js.map +1 -1
  26. package/dist/agents/core/types.d.ts +1 -0
  27. package/dist/agents/core/types.d.ts.map +1 -1
  28. package/dist/agents/plugins/codex/codex.reconciliation.d.ts +15 -35
  29. package/dist/agents/plugins/codex/codex.reconciliation.d.ts.map +1 -1
  30. package/dist/agents/plugins/codex/codex.reconciliation.js +8 -139
  31. package/dist/agents/plugins/codex/codex.reconciliation.js.map +1 -1
  32. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts +4 -0
  33. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts.map +1 -1
  34. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js +4 -0
  35. package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js.map +1 -1
  36. package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts +8 -0
  37. package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts.map +1 -0
  38. package/dist/agents/plugins/copilot-cli/copilot-cli.models.js +195 -0
  39. package/dist/agents/plugins/copilot-cli/copilot-cli.models.js.map +1 -0
  40. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts +4 -20
  41. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts.map +1 -1
  42. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js +237 -38
  43. package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js.map +1 -1
  44. package/dist/agents/plugins/copilot-cli/copilot-cli.session.d.ts.map +1 -1
  45. package/dist/agents/plugins/copilot-cli/copilot-cli.session.js +14 -2
  46. package/dist/agents/plugins/copilot-cli/copilot-cli.session.js.map +1 -1
  47. package/dist/agents/plugins/copilot-cli/index.d.ts +2 -1
  48. package/dist/agents/plugins/copilot-cli/index.d.ts.map +1 -1
  49. package/dist/agents/plugins/copilot-cli/index.js +2 -1
  50. package/dist/agents/plugins/copilot-cli/index.js.map +1 -1
  51. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts +6 -3
  52. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts.map +1 -1
  53. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js +298 -5
  54. package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js.map +1 -1
  55. package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts +12 -0
  56. package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts.map +1 -0
  57. package/dist/agents/plugins/pi/__tests__/home-redirect.js +27 -0
  58. package/dist/agents/plugins/pi/__tests__/home-redirect.js.map +1 -0
  59. package/dist/agents/plugins/pi/extension/README.md +68 -0
  60. package/dist/agents/plugins/pi/extension/index.js +161 -0
  61. package/dist/agents/plugins/pi/extension/package.json +8 -0
  62. package/dist/agents/plugins/pi/index.d.ts +3 -0
  63. package/dist/agents/plugins/pi/index.d.ts.map +1 -0
  64. package/dist/agents/plugins/pi/index.js +3 -0
  65. package/dist/agents/plugins/pi/index.js.map +1 -0
  66. package/dist/agents/plugins/pi/pi.extension.d.ts +60 -0
  67. package/dist/agents/plugins/pi/pi.extension.d.ts.map +1 -0
  68. package/dist/agents/plugins/pi/pi.extension.js +201 -0
  69. package/dist/agents/plugins/pi/pi.extension.js.map +1 -0
  70. package/dist/agents/plugins/pi/pi.incremental-sync.d.ts +63 -0
  71. package/dist/agents/plugins/pi/pi.incremental-sync.d.ts.map +1 -0
  72. package/dist/agents/plugins/pi/pi.incremental-sync.js +266 -0
  73. package/dist/agents/plugins/pi/pi.incremental-sync.js.map +1 -0
  74. package/dist/agents/plugins/pi/pi.models.d.ts +20 -0
  75. package/dist/agents/plugins/pi/pi.models.d.ts.map +1 -0
  76. package/dist/agents/plugins/pi/pi.models.js +201 -0
  77. package/dist/agents/plugins/pi/pi.models.js.map +1 -0
  78. package/dist/agents/plugins/pi/pi.packages.d.ts +11 -0
  79. package/dist/agents/plugins/pi/pi.packages.d.ts.map +1 -0
  80. package/dist/agents/plugins/pi/pi.packages.js +35 -0
  81. package/dist/agents/plugins/pi/pi.packages.js.map +1 -0
  82. package/dist/agents/plugins/pi/pi.paths.d.ts +37 -0
  83. package/dist/agents/plugins/pi/pi.paths.d.ts.map +1 -0
  84. package/dist/agents/plugins/pi/pi.paths.js +146 -0
  85. package/dist/agents/plugins/pi/pi.paths.js.map +1 -0
  86. package/dist/agents/plugins/pi/pi.plugin.d.ts +30 -0
  87. package/dist/agents/plugins/pi/pi.plugin.d.ts.map +1 -0
  88. package/dist/agents/plugins/pi/pi.plugin.js +453 -0
  89. package/dist/agents/plugins/pi/pi.plugin.js.map +1 -0
  90. package/dist/agents/plugins/pi/pi.session.d.ts +114 -0
  91. package/dist/agents/plugins/pi/pi.session.d.ts.map +1 -0
  92. package/dist/agents/plugins/pi/pi.session.js +388 -0
  93. package/dist/agents/plugins/pi/pi.session.js.map +1 -0
  94. package/dist/agents/plugins/pi/pi.setup.d.ts +2 -0
  95. package/dist/agents/plugins/pi/pi.setup.d.ts.map +1 -0
  96. package/dist/agents/plugins/pi/pi.setup.js +33 -0
  97. package/dist/agents/plugins/pi/pi.setup.js.map +1 -0
  98. package/dist/agents/plugins/pi/pi.types.d.ts +143 -0
  99. package/dist/agents/plugins/pi/pi.types.d.ts.map +1 -0
  100. package/dist/agents/plugins/pi/pi.types.js +74 -0
  101. package/dist/agents/plugins/pi/pi.types.js.map +1 -0
  102. package/dist/agents/plugins/pi/session/pi-file-operations.d.ts +17 -0
  103. package/dist/agents/plugins/pi/session/pi-file-operations.d.ts.map +1 -0
  104. package/dist/agents/plugins/pi/session/pi-file-operations.js +98 -0
  105. package/dist/agents/plugins/pi/session/pi-file-operations.js.map +1 -0
  106. package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts +52 -0
  107. package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts.map +1 -0
  108. package/dist/agents/plugins/pi/session/pi-named-invocations.js +189 -0
  109. package/dist/agents/plugins/pi/session/pi-named-invocations.js.map +1 -0
  110. package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts +14 -0
  111. package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts.map +1 -0
  112. package/dist/agents/plugins/pi/session/pi-user-prompt.js +51 -0
  113. package/dist/agents/plugins/pi/session/pi-user-prompt.js.map +1 -0
  114. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts +52 -0
  115. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts.map +1 -0
  116. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js +716 -0
  117. package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js.map +1 -0
  118. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts +104 -0
  119. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts.map +1 -0
  120. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js +595 -0
  121. package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js.map +1 -0
  122. package/dist/agents/registry.d.ts.map +1 -1
  123. package/dist/agents/registry.js +2 -2
  124. package/dist/agents/registry.js.map +1 -1
  125. package/dist/cli/commands/analytics/agent-labels.d.ts.map +1 -1
  126. package/dist/cli/commands/analytics/agent-labels.js +1 -0
  127. package/dist/cli/commands/analytics/agent-labels.js.map +1 -1
  128. package/dist/cli/commands/analytics/cost/usage-readers.d.ts +24 -0
  129. package/dist/cli/commands/analytics/cost/usage-readers.d.ts.map +1 -1
  130. package/dist/cli/commands/analytics/cost/usage-readers.js +199 -54
  131. package/dist/cli/commands/analytics/cost/usage-readers.js.map +1 -1
  132. package/dist/cli/commands/analytics/index.js +1 -0
  133. package/dist/cli/commands/analytics/index.js.map +1 -1
  134. package/dist/cli/commands/analytics/native-loader.d.ts +21 -4
  135. package/dist/cli/commands/analytics/native-loader.d.ts.map +1 -1
  136. package/dist/cli/commands/analytics/native-loader.js +250 -96
  137. package/dist/cli/commands/analytics/native-loader.js.map +1 -1
  138. package/dist/cli/commands/analytics/report/client/app.js +47 -3
  139. package/dist/cli/commands/analytics/report/payload-builder.d.ts.map +1 -1
  140. package/dist/cli/commands/analytics/report/payload-builder.js +25 -2
  141. package/dist/cli/commands/analytics/report/payload-builder.js.map +1 -1
  142. package/dist/cli/commands/analytics/report/types.d.ts +1 -0
  143. package/dist/cli/commands/analytics/report/types.d.ts.map +1 -1
  144. package/dist/cli/commands/hook.d.ts.map +1 -1
  145. package/dist/cli/commands/hook.js +71 -29
  146. package/dist/cli/commands/hook.js.map +1 -1
  147. package/dist/cli/commands/install.d.ts.map +1 -1
  148. package/dist/cli/commands/install.js +7 -5
  149. package/dist/cli/commands/install.js.map +1 -1
  150. package/dist/cli/commands/list.d.ts.map +1 -1
  151. package/dist/cli/commands/list.js +3 -1
  152. package/dist/cli/commands/list.js.map +1 -1
  153. package/dist/cli/commands/uninstall.d.ts.map +1 -1
  154. package/dist/cli/commands/uninstall.js +5 -3
  155. package/dist/cli/commands/uninstall.js.map +1 -1
  156. package/dist/cli/commands/update.d.ts.map +1 -1
  157. package/dist/cli/commands/update.js +5 -3
  158. package/dist/cli/commands/update.js.map +1 -1
  159. package/dist/cli/first-time.d.ts.map +1 -1
  160. package/dist/cli/first-time.js +7 -6
  161. package/dist/cli/first-time.js.map +1 -1
  162. package/dist/providers/core/auth-validation.d.ts +7 -2
  163. package/dist/providers/core/auth-validation.d.ts.map +1 -1
  164. package/dist/providers/core/auth-validation.js +11 -5
  165. package/dist/providers/core/auth-validation.js.map +1 -1
  166. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts +8 -3
  167. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts.map +1 -1
  168. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js +46 -11
  169. package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js.map +1 -1
  170. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts +23 -13
  171. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts.map +1 -1
  172. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js +75 -18
  173. package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js.map +1 -1
  174. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts +21 -0
  175. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts.map +1 -0
  176. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js +133 -0
  177. package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js.map +1 -0
  178. package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js +1 -1
  179. package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js.map +1 -1
  180. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +2 -1
  181. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  182. package/dist/providers/plugins/sso/proxy/plugins/index.js +4 -2
  183. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  184. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts +11 -0
  185. package/dist/providers/plugins/sso/proxy/plugins/types.d.ts.map +1 -1
  186. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts +2 -0
  187. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts.map +1 -1
  188. package/dist/providers/plugins/sso/proxy/sso.proxy.js +37 -1
  189. package/dist/providers/plugins/sso/proxy/sso.proxy.js.map +1 -1
  190. package/dist/providers/plugins/sso/session/SessionSyncer.d.ts.map +1 -1
  191. package/dist/providers/plugins/sso/session/SessionSyncer.js +13 -0
  192. package/dist/providers/plugins/sso/session/SessionSyncer.js.map +1 -1
  193. package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js +6 -0
  194. package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js.map +1 -1
  195. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts +0 -6
  196. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts.map +1 -1
  197. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js +28 -19
  198. package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js.map +1 -1
  199. package/dist/utils/interactive.d.ts +14 -0
  200. package/dist/utils/interactive.d.ts.map +1 -0
  201. package/dist/utils/interactive.js +16 -0
  202. package/dist/utils/interactive.js.map +1 -0
  203. package/package.json +6 -4
  204. package/scripts/copy-plugins.js +6 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.plugin.js","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,GAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oDAAoD,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD;;;;;;GAMG;AACH,MAAM,0BAA0B,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;AAEvF;;;;GAIG;AACH,SAAS,aAAa,CAAC,IAAc,EAAE,IAAY;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,C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ACD,iBAAiB,CAAC,GAAG,EAAE,SAAS,CAAC,CAClC,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,8CAA8C,SAAS,EAAE,CAAC,CAAC;YACzE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACnE,MAAM,CAAC,KAAK,CAAC,+CAA+C,GAAG,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;KACF;CACF,CAAC;AAEF,MAAM,OAAO,QAAS,SAAQ,gBAAgB;IACpC,cAAc,CAAiB;IAEvC;QACE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG,CACP,IAAc,EACd,YAAqC,EACrC,UAAiC;QAEjC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,sBAAsB,CAC1B,QAAiE;QAEjE,MAAM,yBAAyB,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Pi Session Adapter
3
+ *
4
+ * Discovers and parses Pi JSONL session files, then runs the metrics processor.
5
+ */
6
+ import type { SessionAdapter, ParsedSession, AggregatedResult, SessionDiscoveryOptions, SessionDescriptor } from '../../core/session/BaseSessionAdapter.js';
7
+ import type { SessionProcessor, ProcessingContext } from '../../core/session/BaseProcessor.js';
8
+ import type { AgentMetadata } from '../../core/types.js';
9
+ export interface PiDiscoveryOptions extends SessionDiscoveryOptions {
10
+ /** Environment variables used to resolve Pi session-directory overrides. */
11
+ env?: NodeJS.ProcessEnv;
12
+ }
13
+ /** One transcript linked to a parsed session, as {@link ParsedSession.subagents} carries it. */
14
+ type LinkedTranscript = NonNullable<ParsedSession['subagents']>[number];
15
+ /**
16
+ * `subagents[].agentType` for a nested sub-agent run: a delegated agent Pi ran under this
17
+ * transcript, stored at `<transcript-without-.jsonl>/<agentId>/run-N/session.jsonl`.
18
+ */
19
+ export declare const PI_SUBAGENT_RUN = "pi-subagent-run";
20
+ /**
21
+ * `subagents[].agentType` for a transcript that CONTINUED this one (`/fork`, `/branch`).
22
+ * Its inherited entries are byte-identical copies of this transcript's, ids included, so
23
+ * consumers must fold it in by entry identity rather than concatenating blindly.
24
+ *
25
+ * Never attached by this adapter — see {@link PiSessionAdapter.loadSubagentRuns} for why folding
26
+ * a fork family is the analytics layer's job. `native-loader.ts` attaches it.
27
+ */
28
+ export declare const PI_FORKED_CONTINUATION = "pi-forked-continuation";
29
+ /** The transcripts that continued `parsed` via `/fork` or `/branch`, in discovery order. */
30
+ export declare function piForkedContinuations(parsed: ParsedSession): LinkedTranscript[];
31
+ import { type PiLedgerInvocations } from './session/processors/pi.metrics-processor.js';
32
+ export declare class PiSessionAdapter implements SessionAdapter {
33
+ private readonly metadata;
34
+ readonly agentName = "pi";
35
+ private processors;
36
+ constructor(metadata: AgentMetadata);
37
+ private initializeProcessors;
38
+ /**
39
+ * Supply the run-ledger counts the metrics processor cannot derive from a transcript.
40
+ *
41
+ * Pi expands a prompt template into plain user text before persisting it, so `/review` never
42
+ * appears in the JSONL — the only record of it is the ledger the CodeMie extension wrote
43
+ * (`pi.extension.ts`). The processing pipeline reaches this adapter through the registry
44
+ * singleton, and `ProcessingContext` is shared by every agent, so the counts are handed over
45
+ * here rather than threaded through a field only Pi would ever read.
46
+ */
47
+ setLedgerInvocations(ledgerInvocations: PiLedgerInvocations | undefined): void;
48
+ registerProcessor(processor: SessionProcessor): void;
49
+ parseSessionFile(filePath: string, sessionId: string): Promise<ParsedSession>;
50
+ /**
51
+ * Nested sub-agent transcripts, stored under `<transcript-without-.jsonl>/<agentId>/run-N/`.
52
+ *
53
+ * A delegated agent gets its own session file there. The parent records tool results for those
54
+ * dispatches but NO usage on them (measured on a real corpus: 1707 `toolResult` entries, zero
55
+ * carrying `usage`), so every token a sub-agent burned lives only in the nested file and a
56
+ * reader that walks `messages` alone misses all of it.
57
+ *
58
+ * Attached WITHOUT a `toolUseId`: this is session-level spend, not the allocation of one
59
+ * dispatch, and `cost-enricher.enrichDispatchCosts` keys on `toolUseId` precisely so it skips
60
+ * these.
61
+ *
62
+ * **Forked continuations are deliberately NOT linked here.** `/fork` writes a new file that
63
+ * replays the prior conversation verbatim, so folding it into its source looks tempting — but
64
+ * `codemie pi --fork` is a second MANAGED run with a CodeMie session of its own, and the cost
65
+ * enricher walks sessions in `startTime` order against a shared `seen` set. Anything attached
66
+ * to the earlier session's transcript is consumed by the earlier session, so the forked run
67
+ * reports as free and its spend lands on the wrong session, date and branch. Collapsing a fork
68
+ * family is the analytics layer's job, where the set of sessions being reported is known;
69
+ * `native-loader.ts` does it for untracked runs.
70
+ *
71
+ * This is identity, not attribution: a directory Pi named after this transcript. Nothing here
72
+ * guesses ownership from mtime, id shape, or timing — see {@link discoverSessions}.
73
+ */
74
+ private loadSubagentRuns;
75
+ private static readonly HEADER_READ_BYTES;
76
+ private readSessionHeader;
77
+ private readJsonlFile;
78
+ processSession(filePath: string, sessionId: string, context: ProcessingContext): Promise<AggregatedResult>;
79
+ /**
80
+ * Enumerate the Pi transcripts visible from this project.
81
+ *
82
+ * This is a plain listing, and deliberately so: it answers "which Pi transcripts
83
+ * exist here", never "which of them belong to the run that just finished".
84
+ *
85
+ * That second question cannot be answered from a directory. A concurrent `pi` — or
86
+ * a second CodeMie run in the same cwd — writes files indistinguishable from this
87
+ * run's by id, mtime, or `parentSession` lineage, and claiming one of them uploads
88
+ * a stranger's prompts and tool output under this user's session. Successive
89
+ * rounds of increasingly careful heuristics here were each shown to be reachable-
90
+ * wrong, so ownership is no longer inferred at all: the CodeMie extension records
91
+ * each transcript path from inside Pi, and `readPiRunLedger` reads it back.
92
+ *
93
+ * Scope follows the caller. With a `cwd`, the listing is that project's: the transcripts in
94
+ * that project's session directory whose own header declares that cwd — what a managed run
95
+ * needs. Without one, the listing is every project's, because that is what analytics needs:
96
+ * Claude and Codex discovery is global, so a cwd-scoped Pi would report zero usage whenever
97
+ * `codemie analytics` is run from anywhere but the project directory.
98
+ *
99
+ * @see pi.extension.ts
100
+ */
101
+ discoverSessions(options?: SessionDiscoveryOptions): Promise<SessionDescriptor[]>;
102
+ /**
103
+ * Every transcript in `sessionDir` recent enough to matter, optionally narrowed to one project.
104
+ *
105
+ * A session directory can be shared between projects (`--session-dir`, or a
106
+ * `sessionDir` in the project's `.pi/settings.json`), so when a `projectPath` is
107
+ * given each file's own header must declare that cwd. Filtering is on mtime rather
108
+ * than header timestamp so a long-running session is not dropped while it is still
109
+ * being written to.
110
+ */
111
+ private listTranscripts;
112
+ }
113
+ export {};
114
+ //# sourceMappingURL=pi.session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.session.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC5J,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIzD,MAAM,WAAW,kBAAmB,SAAQ,uBAAuB;IACjE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AAC,iBAAiB,EAAE,CAAC;IAuBvF;;;;;;;;OAQG;YACW,eAAe;CAqD9B"}
@@ -0,0 +1,388 @@
1
+ /**
2
+ * Pi Session Adapter
3
+ *
4
+ * Discovers and parses Pi JSONL session files, then runs the metrics processor.
5
+ */
6
+ import { open, readFile, readdir, stat } from 'fs/promises';
7
+ import { dirname, join, resolve } from 'path';
8
+ import { existsSync } from 'fs';
9
+ import { logger } from '../../../utils/logger.js';
10
+ import { getUserPiAgentDir, resolvePiSessionDir } from './pi.paths.js';
11
+ /**
12
+ * `subagents[].agentType` for a nested sub-agent run: a delegated agent Pi ran under this
13
+ * transcript, stored at `<transcript-without-.jsonl>/<agentId>/run-N/session.jsonl`.
14
+ */
15
+ export const PI_SUBAGENT_RUN = 'pi-subagent-run';
16
+ /**
17
+ * `subagents[].agentType` for a transcript that CONTINUED this one (`/fork`, `/branch`).
18
+ * Its inherited entries are byte-identical copies of this transcript's, ids included, so
19
+ * consumers must fold it in by entry identity rather than concatenating blindly.
20
+ *
21
+ * Never attached by this adapter — see {@link PiSessionAdapter.loadSubagentRuns} for why folding
22
+ * a fork family is the analytics layer's job. `native-loader.ts` attaches it.
23
+ */
24
+ export const PI_FORKED_CONTINUATION = 'pi-forked-continuation';
25
+ /** The transcripts that continued `parsed` via `/fork` or `/branch`, in discovery order. */
26
+ export function piForkedContinuations(parsed) {
27
+ return (parsed.subagents ?? []).filter((sub) => sub.agentType === PI_FORKED_CONTINUATION);
28
+ }
29
+ /** The immediate subdirectories of `root`, or [] when it is absent or unreadable. */
30
+ async function subdirectoriesOf(root) {
31
+ try {
32
+ const entries = await readdir(root, { withFileTypes: true });
33
+ return entries.filter((e) => e.isDirectory()).map((e) => join(root, e.name));
34
+ }
35
+ catch {
36
+ return [];
37
+ }
38
+ }
39
+ /**
40
+ * Every project's session directory, for an unscoped (analytics) listing.
41
+ *
42
+ * Pi transcripts live under TWO roots, and a listing that reads one of them is blind to
43
+ * whichever half of the user's usage lives in the other:
44
+ *
45
+ * - `<cwd>/.pi/codemie/agent/sessions` — where CodeMie points Pi (`beforeRun` sets
46
+ * `PI_CODING_AGENT_DIR`), so every MANAGED run lands here. In practice it holds exactly
47
+ * one directory, the project's own.
48
+ * - `~/.pi/agent/sessions` — Pi's own default (upstream `getDefaultSessionDir`), so every
49
+ * BARE `pi` run lands here. Native discovery exists precisely to report those runs, and
50
+ * this is the only root that has them.
51
+ *
52
+ * Both use the same one-directory-per-cwd layout, so a root's subdirectories ARE the projects.
53
+ * A directory the user pointed Pi at explicitly (`PI_CODING_AGENT_SESSION_DIR`, or `sessionDir`
54
+ * in settings) is not part of that layout — its siblings are arbitrary directories that have
55
+ * nothing to do with Pi — so a custom resolution stays alone.
56
+ */
57
+ async function allProjectSessionDirs(resolution) {
58
+ const { sessionDir, isCustom } = resolution;
59
+ if (isCustom) {
60
+ return [sessionDir];
61
+ }
62
+ const dirs = [];
63
+ const seen = new Set();
64
+ for (const root of [dirname(sessionDir), join(getUserPiAgentDir(), 'sessions')]) {
65
+ for (const dir of await subdirectoriesOf(root)) {
66
+ const key = resolve(dir);
67
+ if (seen.has(key))
68
+ continue;
69
+ seen.add(key);
70
+ dirs.push(dir);
71
+ }
72
+ }
73
+ // Both roots unreadable — fall back to the project's own directory.
74
+ return dirs.length > 0 ? dirs : [sessionDir];
75
+ }
76
+ import { PI_METRICS_PROCESSOR_NAME, PiMetricsProcessor, } from './session/processors/pi.metrics-processor.js';
77
+ import { PiConversationsProcessor } from './session/processors/pi.conversations-processor.js';
78
+ import { isPiSessionHeader } from './pi.types.js';
79
+ export class PiSessionAdapter {
80
+ metadata;
81
+ agentName = 'pi';
82
+ processors = [];
83
+ constructor(metadata) {
84
+ this.metadata = metadata;
85
+ this.initializeProcessors();
86
+ }
87
+ initializeProcessors() {
88
+ this.registerProcessor(new PiMetricsProcessor(this.metadata));
89
+ this.registerProcessor(new PiConversationsProcessor());
90
+ logger.debug(`[pi-adapter] Initialized ${this.processors.length} processors`);
91
+ }
92
+ /**
93
+ * Supply the run-ledger counts the metrics processor cannot derive from a transcript.
94
+ *
95
+ * Pi expands a prompt template into plain user text before persisting it, so `/review` never
96
+ * appears in the JSONL — the only record of it is the ledger the CodeMie extension wrote
97
+ * (`pi.extension.ts`). The processing pipeline reaches this adapter through the registry
98
+ * singleton, and `ProcessingContext` is shared by every agent, so the counts are handed over
99
+ * here rather than threaded through a field only Pi would ever read.
100
+ */
101
+ setLedgerInvocations(ledgerInvocations) {
102
+ this.processors = this.processors.filter((processor) => processor.name !== PI_METRICS_PROCESSOR_NAME);
103
+ this.registerProcessor(new PiMetricsProcessor(this.metadata, ledgerInvocations));
104
+ }
105
+ registerProcessor(processor) {
106
+ this.processors.push(processor);
107
+ this.processors.sort((a, b) => a.priority - b.priority);
108
+ logger.debug(`[pi-adapter] Registered processor: ${processor.name} (priority: ${processor.priority})`);
109
+ }
110
+ async parseSessionFile(filePath, sessionId) {
111
+ try {
112
+ const entries = await this.readJsonlFile(filePath);
113
+ const header = await this.readSessionHeader(filePath);
114
+ const projectPath = header?.cwd ?? process.cwd();
115
+ const subagents = await this.loadSubagentRuns(filePath);
116
+ return {
117
+ sessionId,
118
+ agentName: this.metadata.displayName || 'Pi',
119
+ metadata: {
120
+ projectPath,
121
+ ...(header?.timestamp && { createdAt: header.timestamp }),
122
+ ...(header?.id && { agentSessionId: header.id }),
123
+ // The file's own statement of which transcript it was forked from. Analytics uses
124
+ // it to collapse a fork family into the one conversation it really is.
125
+ ...(header?.parentSession && { parentSession: header.parentSession }),
126
+ },
127
+ messages: entries,
128
+ ...(subagents.length > 0 && { subagents }),
129
+ };
130
+ }
131
+ catch (error) {
132
+ logger.error(`[pi-adapter] Failed to parse session file ${filePath}:`, error);
133
+ throw error;
134
+ }
135
+ }
136
+ /**
137
+ * Nested sub-agent transcripts, stored under `<transcript-without-.jsonl>/<agentId>/run-N/`.
138
+ *
139
+ * A delegated agent gets its own session file there. The parent records tool results for those
140
+ * dispatches but NO usage on them (measured on a real corpus: 1707 `toolResult` entries, zero
141
+ * carrying `usage`), so every token a sub-agent burned lives only in the nested file and a
142
+ * reader that walks `messages` alone misses all of it.
143
+ *
144
+ * Attached WITHOUT a `toolUseId`: this is session-level spend, not the allocation of one
145
+ * dispatch, and `cost-enricher.enrichDispatchCosts` keys on `toolUseId` precisely so it skips
146
+ * these.
147
+ *
148
+ * **Forked continuations are deliberately NOT linked here.** `/fork` writes a new file that
149
+ * replays the prior conversation verbatim, so folding it into its source looks tempting — but
150
+ * `codemie pi --fork` is a second MANAGED run with a CodeMie session of its own, and the cost
151
+ * enricher walks sessions in `startTime` order against a shared `seen` set. Anything attached
152
+ * to the earlier session's transcript is consumed by the earlier session, so the forked run
153
+ * reports as free and its spend lands on the wrong session, date and branch. Collapsing a fork
154
+ * family is the analytics layer's job, where the set of sessions being reported is known;
155
+ * `native-loader.ts` does it for untracked runs.
156
+ *
157
+ * This is identity, not attribution: a directory Pi named after this transcript. Nothing here
158
+ * guesses ownership from mtime, id shape, or timing — see {@link discoverSessions}.
159
+ */
160
+ async loadSubagentRuns(transcriptPath) {
161
+ if (!transcriptPath.endsWith('.jsonl')) {
162
+ return [];
163
+ }
164
+ const runsRoot = transcriptPath.slice(0, -'.jsonl'.length);
165
+ let agentDirs;
166
+ try {
167
+ agentDirs = await readdir(runsRoot);
168
+ }
169
+ catch {
170
+ return []; // no sub-agent ran under this transcript
171
+ }
172
+ const out = [];
173
+ for (const agentDir of agentDirs.sort()) {
174
+ let runDirs;
175
+ try {
176
+ runDirs = await readdir(join(runsRoot, agentDir));
177
+ }
178
+ catch {
179
+ continue;
180
+ }
181
+ for (const runDir of runDirs.sort()) {
182
+ const sessionPath = join(runsRoot, agentDir, runDir, 'session.jsonl');
183
+ if (!existsSync(sessionPath)) {
184
+ continue;
185
+ }
186
+ try {
187
+ out.push({
188
+ agentId: `${agentDir}/${runDir}`,
189
+ filePath: sessionPath,
190
+ agentType: PI_SUBAGENT_RUN,
191
+ messages: (await this.readJsonlFile(sessionPath)),
192
+ });
193
+ }
194
+ catch {
195
+ logger.debug(`[pi-adapter] Could not read sub-agent run: ${sessionPath}`);
196
+ }
197
+ }
198
+ }
199
+ return out;
200
+ }
201
+ static HEADER_READ_BYTES = 65536;
202
+ async readSessionHeader(filePath) {
203
+ let handle;
204
+ try {
205
+ handle = await open(filePath, 'r');
206
+ const buffer = Buffer.alloc(PiSessionAdapter.HEADER_READ_BYTES);
207
+ const { bytesRead } = await handle.read(buffer, 0, PiSessionAdapter.HEADER_READ_BYTES, 0);
208
+ if (bytesRead === 0)
209
+ return undefined;
210
+ const firstLine = buffer.toString('utf-8', 0, bytesRead).split('\n')[0]?.trim();
211
+ if (!firstLine)
212
+ return undefined;
213
+ const parsed = JSON.parse(firstLine);
214
+ if (isPiSessionHeader(parsed)) {
215
+ return parsed;
216
+ }
217
+ }
218
+ catch {
219
+ // ignore — malformed header is handled by caller
220
+ }
221
+ finally {
222
+ await handle?.close().catch(() => {
223
+ // best-effort close
224
+ });
225
+ }
226
+ return undefined;
227
+ }
228
+ async readJsonlFile(filePath) {
229
+ const content = await readFile(filePath, 'utf-8');
230
+ const entries = [];
231
+ for (const line of content.split('\n')) {
232
+ const trimmed = line.trim();
233
+ if (!trimmed)
234
+ continue;
235
+ try {
236
+ const parsed = JSON.parse(trimmed);
237
+ if (parsed && typeof parsed === 'object') {
238
+ entries.push(parsed);
239
+ }
240
+ else {
241
+ logger.debug(`[pi-adapter] Skipping non-object JSONL line in ${filePath}`);
242
+ }
243
+ }
244
+ catch {
245
+ logger.debug(`[pi-adapter] Skipping malformed JSONL line in ${filePath}`);
246
+ }
247
+ }
248
+ return entries;
249
+ }
250
+ async processSession(filePath, sessionId, context) {
251
+ const parsedSession = await this.parseSessionFile(filePath, sessionId);
252
+ if (context.gitBranch && parsedSession.metadata) {
253
+ parsedSession.metadata.gitBranch = context.gitBranch;
254
+ }
255
+ const processorResults = {};
256
+ const failedProcessors = [];
257
+ let totalRecords = 0;
258
+ for (const processor of this.processors) {
259
+ try {
260
+ if (!processor.shouldProcess(parsedSession)) {
261
+ logger.debug(`[pi-adapter] Processor ${processor.name} skipped`);
262
+ continue;
263
+ }
264
+ const result = await processor.process(parsedSession, context);
265
+ processorResults[processor.name] = {
266
+ success: result.success,
267
+ message: result.message,
268
+ recordsProcessed: result.metadata?.recordsProcessed,
269
+ };
270
+ if (!result.success) {
271
+ failedProcessors.push(processor.name);
272
+ }
273
+ if (typeof result.metadata?.recordsProcessed === 'number') {
274
+ totalRecords += result.metadata.recordsProcessed;
275
+ }
276
+ }
277
+ catch (error) {
278
+ const msg = error instanceof Error ? error.message : 'Unknown error';
279
+ logger.error(`[pi-adapter] Processor ${processor.name} threw:`, error);
280
+ processorResults[processor.name] = { success: false, message: msg };
281
+ failedProcessors.push(processor.name);
282
+ }
283
+ }
284
+ return {
285
+ success: failedProcessors.length === 0,
286
+ processors: processorResults,
287
+ totalRecords,
288
+ failedProcessors,
289
+ };
290
+ }
291
+ /**
292
+ * Enumerate the Pi transcripts visible from this project.
293
+ *
294
+ * This is a plain listing, and deliberately so: it answers "which Pi transcripts
295
+ * exist here", never "which of them belong to the run that just finished".
296
+ *
297
+ * That second question cannot be answered from a directory. A concurrent `pi` — or
298
+ * a second CodeMie run in the same cwd — writes files indistinguishable from this
299
+ * run's by id, mtime, or `parentSession` lineage, and claiming one of them uploads
300
+ * a stranger's prompts and tool output under this user's session. Successive
301
+ * rounds of increasingly careful heuristics here were each shown to be reachable-
302
+ * wrong, so ownership is no longer inferred at all: the CodeMie extension records
303
+ * each transcript path from inside Pi, and `readPiRunLedger` reads it back.
304
+ *
305
+ * Scope follows the caller. With a `cwd`, the listing is that project's: the transcripts in
306
+ * that project's session directory whose own header declares that cwd — what a managed run
307
+ * needs. Without one, the listing is every project's, because that is what analytics needs:
308
+ * Claude and Codex discovery is global, so a cwd-scoped Pi would report zero usage whenever
309
+ * `codemie analytics` is run from anywhere but the project directory.
310
+ *
311
+ * @see pi.extension.ts
312
+ */
313
+ async discoverSessions(options) {
314
+ const piOptions = options;
315
+ const projectScoped = piOptions?.cwd !== undefined;
316
+ const cwd = piOptions?.cwd ?? process.cwd();
317
+ const resolution = resolvePiSessionDir(cwd, piOptions?.env);
318
+ const maxAgeDays = piOptions?.maxAgeDays ?? 30;
319
+ const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1000;
320
+ const sessionDirs = projectScoped ? [resolution.sessionDir] : await allProjectSessionDirs(resolution);
321
+ const found = [];
322
+ for (const dir of sessionDirs) {
323
+ found.push(...(await this.listTranscripts(dir, cutoff, projectScoped ? cwd : undefined)));
324
+ }
325
+ found.sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0));
326
+ const limited = piOptions?.limit && piOptions.limit > 0 ? found.slice(0, piOptions.limit) : found;
327
+ logger.debug(`[pi-discovery] ${found.length} transcript(s) in ${sessionDirs.length} dir(s), returning ${limited.length}`);
328
+ return limited;
329
+ }
330
+ /**
331
+ * Every transcript in `sessionDir` recent enough to matter, optionally narrowed to one project.
332
+ *
333
+ * A session directory can be shared between projects (`--session-dir`, or a
334
+ * `sessionDir` in the project's `.pi/settings.json`), so when a `projectPath` is
335
+ * given each file's own header must declare that cwd. Filtering is on mtime rather
336
+ * than header timestamp so a long-running session is not dropped while it is still
337
+ * being written to.
338
+ */
339
+ async listTranscripts(sessionDir, cutoff, projectPath) {
340
+ if (!existsSync(sessionDir)) {
341
+ return [];
342
+ }
343
+ const resolvedCwd = projectPath === undefined ? undefined : resolve(projectPath);
344
+ const transcripts = [];
345
+ try {
346
+ for (const file of await readdir(sessionDir)) {
347
+ if (!file.endsWith('.jsonl'))
348
+ continue;
349
+ const filePath = join(sessionDir, file);
350
+ let statResult;
351
+ try {
352
+ statResult = await stat(filePath);
353
+ }
354
+ catch {
355
+ continue;
356
+ }
357
+ if (!statResult.isFile())
358
+ continue;
359
+ const updatedAt = statResult.mtime.getTime();
360
+ if (updatedAt < cutoff)
361
+ continue;
362
+ const header = await this.readSessionHeader(filePath);
363
+ if (!header) {
364
+ logger.debug(`[pi-discovery] Skipping file with invalid header: ${filePath}`);
365
+ continue;
366
+ }
367
+ if (resolvedCwd !== undefined && resolve(header.cwd) !== resolvedCwd) {
368
+ logger.debug(`[pi-discovery] Skipping session from different cwd: ${header.cwd}`);
369
+ continue;
370
+ }
371
+ const createdAt = Date.parse(header.timestamp);
372
+ transcripts.push({
373
+ sessionId: header.id,
374
+ filePath,
375
+ projectPath: header.cwd,
376
+ createdAt: Number.isNaN(createdAt) ? updatedAt : createdAt,
377
+ updatedAt,
378
+ agentName: 'pi',
379
+ });
380
+ }
381
+ }
382
+ catch (error) {
383
+ logger.debug(`[pi-discovery] Failed to scan session dir ${sessionDir}:`, error);
384
+ }
385
+ return transcripts;
386
+ }
387
+ }
388
+ //# sourceMappingURL=pi.session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.session.js","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAIhC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAA+B,MAAM,eAAe,CAAC;AAUpG;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,4FAA4F;AAC5F,MAAM,UAAU,qBAAqB,CAAC,MAAqB;IACzD,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,C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,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;gBACtD,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,CAAC,KAAK,CAAC,qDAAqD,QAAQ,EAAE,CAAC,CAAC;oBAC9E,SAAS;gBACX,CAAC;gBACD,IAAI,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,WAAW,EAAE,CAAC;oBACrE,MAAM,CAAC,KAAK,CAAC,uDAAuD,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;oBAClF,SAAS;gBACX,CAAC;gBAED,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC/C,WAAW,CAAC,IAAI,CAAC;oBACf,SAAS,EAAE,MAAM,CAAC,EAAE;oBACpB,QAAQ;oBACR,WAAW,EAAE,MAAM,CAAC,GAAG;oBACvB,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;oBAC1D,SAAS;oBACT,SAAS,EAAE,IAAI;iBAChB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,6CAA6C,UAAU,GAAG,EAAE,KAAK,CAAC,CAAC;QAClF,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function preparePiAgentDir(cwd?: string): Promise<void>;
2
+ //# sourceMappingURL=pi.setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.setup.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.setup.ts"],"names":[],"mappings":"AAMA,wBAAsB,iBAAiB,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BlF"}
@@ -0,0 +1,33 @@
1
+ import { existsSync } from 'fs';
2
+ import { cp, mkdir } from 'fs/promises';
3
+ import { join } from 'path';
4
+ import { logger } from '../../../utils/logger.js';
5
+ import { getPiAgentDir, getUserPiAgentDir } from './pi.paths.js';
6
+ export async function preparePiAgentDir(cwd = process.cwd()) {
7
+ const sourceDir = getUserPiAgentDir();
8
+ const destDir = getPiAgentDir(cwd);
9
+ if (existsSync(destDir)) {
10
+ logger.debug(`[pi-setup] CodeMie Pi agent dir already exists, skipping copy: ${destDir}`);
11
+ return;
12
+ }
13
+ if (!existsSync(sourceDir)) {
14
+ logger.warn(`[pi-setup] User Pi agent dir not found, starting fresh: ${sourceDir}`);
15
+ await mkdir(destDir, { recursive: true });
16
+ return;
17
+ }
18
+ logger.debug(`[pi-setup] Copying ${sourceDir} → ${destDir}`);
19
+ try {
20
+ const excludedSessionsDir = join(sourceDir, 'sessions');
21
+ await cp(sourceDir, destDir, {
22
+ recursive: true,
23
+ force: true,
24
+ filter: (source) => source !== excludedSessionsDir,
25
+ });
26
+ }
27
+ catch (error) {
28
+ const message = error instanceof Error ? error.message : String(error);
29
+ logger.warn(`[pi-setup] Failed to copy user Pi agent dir, starting fresh: ${message}`);
30
+ await mkdir(destDir, { recursive: true });
31
+ }
32
+ }
33
+ //# sourceMappingURL=pi.setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pi.setup.js","sourceRoot":"","sources":["../../../../src/agents/plugins/pi/pi.setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,M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