@codemieai/code 0.0.33 → 0.0.35

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 (294) hide show
  1. package/README.md +78 -7
  2. package/bin/codemie-claude-acp.js +21 -0
  3. package/bin/codemie-opencode.js +11 -0
  4. package/bin/codemie.js +13 -0
  5. package/dist/agents/codemie-code/agent.d.ts +38 -4
  6. package/dist/agents/codemie-code/agent.d.ts.map +1 -1
  7. package/dist/agents/codemie-code/agent.js +333 -178
  8. package/dist/agents/codemie-code/agent.js.map +1 -1
  9. package/dist/agents/codemie-code/index.d.ts +2 -1
  10. package/dist/agents/codemie-code/index.d.ts.map +1 -1
  11. package/dist/agents/codemie-code/index.js +36 -7
  12. package/dist/agents/codemie-code/index.js.map +1 -1
  13. package/dist/agents/codemie-code/prompts.d.ts +12 -5
  14. package/dist/agents/codemie-code/prompts.d.ts.map +1 -1
  15. package/dist/agents/codemie-code/prompts.js +53 -6
  16. package/dist/agents/codemie-code/prompts.js.map +1 -1
  17. package/dist/agents/codemie-code/toolMetadata.d.ts.map +1 -1
  18. package/dist/agents/codemie-code/toolMetadata.js +9 -8
  19. package/dist/agents/codemie-code/toolMetadata.js.map +1 -1
  20. package/dist/agents/codemie-code/tools/assistant-invocation.d.ts +47 -0
  21. package/dist/agents/codemie-code/tools/assistant-invocation.d.ts.map +1 -0
  22. package/dist/agents/codemie-code/tools/assistant-invocation.js +129 -0
  23. package/dist/agents/codemie-code/tools/assistant-invocation.js.map +1 -0
  24. package/dist/agents/codemie-code/tools/index.d.ts +70 -4
  25. package/dist/agents/codemie-code/tools/index.d.ts.map +1 -1
  26. package/dist/agents/codemie-code/tools/index.js +57 -44
  27. package/dist/agents/codemie-code/tools/index.js.map +1 -1
  28. package/dist/agents/codemie-code/tools/planning.d.ts +6 -5
  29. package/dist/agents/codemie-code/tools/planning.d.ts.map +1 -1
  30. package/dist/agents/codemie-code/tools/planning.js +12 -10
  31. package/dist/agents/codemie-code/tools/planning.js.map +1 -1
  32. package/dist/agents/codemie-code/types.d.ts +27 -3
  33. package/dist/agents/codemie-code/types.d.ts.map +1 -1
  34. package/dist/agents/codemie-code/types.js +24 -0
  35. package/dist/agents/codemie-code/types.js.map +1 -1
  36. package/dist/agents/codemie-code/ui/autocomplete.d.ts +98 -0
  37. package/dist/agents/codemie-code/ui/autocomplete.d.ts.map +1 -0
  38. package/dist/agents/codemie-code/ui/autocomplete.js +145 -0
  39. package/dist/agents/codemie-code/ui/autocomplete.js.map +1 -0
  40. package/dist/agents/codemie-code/ui/keyHandlers.d.ts +112 -0
  41. package/dist/agents/codemie-code/ui/keyHandlers.d.ts.map +1 -0
  42. package/dist/agents/codemie-code/ui/keyHandlers.js +415 -0
  43. package/dist/agents/codemie-code/ui/keyHandlers.js.map +1 -0
  44. package/dist/agents/codemie-code/ui/mentions.d.ts +86 -0
  45. package/dist/agents/codemie-code/ui/mentions.d.ts.map +1 -0
  46. package/dist/agents/codemie-code/ui/mentions.js +122 -0
  47. package/dist/agents/codemie-code/ui/mentions.js.map +1 -0
  48. package/dist/agents/codemie-code/ui/terminalCodes.d.ts +38 -0
  49. package/dist/agents/codemie-code/ui/terminalCodes.d.ts.map +1 -0
  50. package/dist/agents/codemie-code/ui/terminalCodes.js +42 -0
  51. package/dist/agents/codemie-code/ui/terminalCodes.js.map +1 -0
  52. package/dist/agents/codemie-code/ui/todoPanel.d.ts.map +1 -1
  53. package/dist/agents/codemie-code/ui/todoPanel.js +3 -4
  54. package/dist/agents/codemie-code/ui/todoPanel.js.map +1 -1
  55. package/dist/agents/codemie-code/ui.d.ts +8 -7
  56. package/dist/agents/codemie-code/ui.d.ts.map +1 -1
  57. package/dist/agents/codemie-code/ui.js +87 -145
  58. package/dist/agents/codemie-code/ui.js.map +1 -1
  59. package/dist/agents/core/AgentCLI.d.ts +5 -0
  60. package/dist/agents/core/AgentCLI.d.ts.map +1 -1
  61. package/dist/agents/core/AgentCLI.js +25 -1
  62. package/dist/agents/core/AgentCLI.js.map +1 -1
  63. package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
  64. package/dist/agents/core/BaseAgentAdapter.js +90 -27
  65. package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
  66. package/dist/agents/core/extension/BaseExtensionInstaller.d.ts +7 -1
  67. package/dist/agents/core/extension/BaseExtensionInstaller.d.ts.map +1 -1
  68. package/dist/agents/core/extension/BaseExtensionInstaller.js +58 -15
  69. package/dist/agents/core/extension/BaseExtensionInstaller.js.map +1 -1
  70. package/dist/agents/core/session/BaseSessionAdapter.d.ts +25 -0
  71. package/dist/agents/core/session/BaseSessionAdapter.d.ts.map +1 -1
  72. package/dist/agents/core/session/discovery-types.d.ts +53 -0
  73. package/dist/agents/core/session/discovery-types.d.ts.map +1 -0
  74. package/dist/agents/core/session/discovery-types.js +8 -0
  75. package/dist/agents/core/session/discovery-types.js.map +1 -0
  76. package/dist/agents/core/types.d.ts +62 -0
  77. package/dist/agents/core/types.d.ts.map +1 -1
  78. package/dist/agents/plugins/claude/claude-acp.plugin.d.ts +27 -0
  79. package/dist/agents/plugins/claude/claude-acp.plugin.d.ts.map +1 -0
  80. package/dist/agents/plugins/claude/claude-acp.plugin.js +63 -0
  81. package/dist/agents/plugins/claude/claude-acp.plugin.js.map +1 -0
  82. package/dist/agents/plugins/claude/claude-message-types.d.ts +1 -0
  83. package/dist/agents/plugins/claude/claude-message-types.d.ts.map +1 -1
  84. package/dist/agents/plugins/claude/claude.plugin.d.ts +44 -1
  85. package/dist/agents/plugins/claude/claude.plugin.d.ts.map +1 -1
  86. package/dist/agents/plugins/claude/claude.plugin.js +263 -12
  87. package/dist/agents/plugins/claude/claude.plugin.js.map +1 -1
  88. package/dist/agents/plugins/claude/claude.session.d.ts.map +1 -1
  89. package/dist/agents/plugins/claude/claude.session.js +14 -7
  90. package/dist/agents/plugins/claude/claude.session.js.map +1 -1
  91. package/dist/agents/plugins/claude/plugin/.claude-plugin/plugin.json +1 -1
  92. package/dist/agents/plugins/claude/plugin/README.md +40 -2
  93. package/dist/agents/plugins/claude/plugin/claude-templates/README.md +5 -5
  94. package/dist/agents/plugins/claude/plugin/claude-templates/templates/CLAUDE.md.template +177 -436
  95. package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/code-review-agent-template.md.template +49 -82
  96. package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/refactor-cleaner-agent.md.template +337 -0
  97. package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/solution-architect-agent.md.template +129 -419
  98. package/dist/agents/plugins/claude/plugin/claude-templates/templates/agents/unit-tester-agent.md.template +146 -693
  99. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/api/api-patterns.md.template +110 -138
  100. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/architecture.md.template +197 -0
  101. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/data/database-patterns.md.template +171 -91
  102. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/development/development-practices.md.template +219 -131
  103. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/security/security-practices.md.template +223 -98
  104. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/standards/code-quality.md.template +131 -95
  105. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/testing/testing-patterns.md.template +247 -75
  106. package/dist/agents/plugins/claude/plugin/commands/README.md +133 -0
  107. package/dist/agents/plugins/claude/plugin/commands/codemie-init.md +336 -544
  108. package/dist/agents/plugins/claude/plugin/commands/codemie-subagents.md +233 -504
  109. package/dist/agents/plugins/claude/plugin/commands/memory-add.md +311 -30
  110. package/dist/agents/plugins/claude/plugin/commands/memory-refresh.md +218 -39
  111. package/dist/agents/plugins/claude/session/processors/claude.conversations-processor.d.ts.map +1 -1
  112. package/dist/agents/plugins/claude/session/processors/claude.conversations-processor.js +43 -8
  113. package/dist/agents/plugins/claude/session/processors/claude.conversations-processor.js.map +1 -1
  114. package/dist/agents/plugins/claude/session/processors/claude.metrics-processor.d.ts.map +1 -1
  115. package/dist/agents/plugins/claude/session/processors/claude.metrics-processor.js +68 -40
  116. package/dist/agents/plugins/claude/session/processors/claude.metrics-processor.js.map +1 -1
  117. package/dist/agents/plugins/gemini/gemini.plugin.d.ts.map +1 -1
  118. package/dist/agents/plugins/gemini/gemini.plugin.js +0 -3
  119. package/dist/agents/plugins/gemini/gemini.plugin.js.map +1 -1
  120. package/dist/agents/plugins/opencode/index.d.ts +8 -0
  121. package/dist/agents/plugins/opencode/index.d.ts.map +1 -0
  122. package/dist/agents/plugins/opencode/index.js +12 -0
  123. package/dist/agents/plugins/opencode/index.js.map +1 -0
  124. package/dist/agents/plugins/opencode/opencode-message-types.d.ts +207 -0
  125. package/dist/agents/plugins/opencode/opencode-message-types.d.ts.map +1 -0
  126. package/dist/agents/plugins/opencode/opencode-message-types.js +59 -0
  127. package/dist/agents/plugins/opencode/opencode-message-types.js.map +1 -0
  128. package/dist/agents/plugins/opencode/opencode-model-configs.d.ts +65 -0
  129. package/dist/agents/plugins/opencode/opencode-model-configs.d.ts.map +1 -0
  130. package/dist/agents/plugins/opencode/opencode-model-configs.js +184 -0
  131. package/dist/agents/plugins/opencode/opencode-model-configs.js.map +1 -0
  132. package/dist/agents/plugins/opencode/opencode.paths.d.ts +62 -0
  133. package/dist/agents/plugins/opencode/opencode.paths.d.ts.map +1 -0
  134. package/dist/agents/plugins/opencode/opencode.paths.js +148 -0
  135. package/dist/agents/plugins/opencode/opencode.paths.js.map +1 -0
  136. package/dist/agents/plugins/opencode/opencode.plugin.d.ts +35 -0
  137. package/dist/agents/plugins/opencode/opencode.plugin.d.ts.map +1 -0
  138. package/dist/agents/plugins/opencode/opencode.plugin.js +338 -0
  139. package/dist/agents/plugins/opencode/opencode.plugin.js.map +1 -0
  140. package/dist/agents/plugins/opencode/opencode.session.d.ts +77 -0
  141. package/dist/agents/plugins/opencode/opencode.session.d.ts.map +1 -0
  142. package/dist/agents/plugins/opencode/opencode.session.js +424 -0
  143. package/dist/agents/plugins/opencode/opencode.session.js.map +1 -0
  144. package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts +25 -0
  145. package/dist/agents/plugins/opencode/opencode.storage-utils.d.ts.map +1 -0
  146. package/dist/agents/plugins/opencode/opencode.storage-utils.js +96 -0
  147. package/dist/agents/plugins/opencode/opencode.storage-utils.js.map +1 -0
  148. package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts +30 -0
  149. package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.d.ts.map +1 -0
  150. package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js +116 -0
  151. package/dist/agents/plugins/opencode/session/processors/opencode.conversations-processor.js.map +1 -0
  152. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts +102 -0
  153. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.d.ts.map +1 -0
  154. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js +584 -0
  155. package/dist/agents/plugins/opencode/session/processors/opencode.metrics-processor.js.map +1 -0
  156. package/dist/agents/registry.d.ts +1 -1
  157. package/dist/agents/registry.d.ts.map +1 -1
  158. package/dist/agents/registry.js +5 -1
  159. package/dist/agents/registry.js.map +1 -1
  160. package/dist/cli/commands/assistants/chat.d.ts +11 -0
  161. package/dist/cli/commands/assistants/chat.d.ts.map +1 -0
  162. package/dist/cli/commands/assistants/chat.js +201 -0
  163. package/dist/cli/commands/assistants/chat.js.map +1 -0
  164. package/dist/cli/commands/assistants/constants.d.ts +81 -0
  165. package/dist/cli/commands/assistants/constants.d.ts.map +1 -0
  166. package/dist/cli/commands/assistants/constants.js +75 -0
  167. package/dist/cli/commands/assistants/constants.js.map +1 -0
  168. package/dist/cli/commands/assistants/generators/claude-agent-generator.d.ts +26 -0
  169. package/dist/cli/commands/assistants/generators/claude-agent-generator.d.ts.map +1 -0
  170. package/dist/cli/commands/assistants/generators/claude-agent-generator.js +115 -0
  171. package/dist/cli/commands/assistants/generators/claude-agent-generator.js.map +1 -0
  172. package/dist/cli/commands/assistants/index.d.ts +11 -0
  173. package/dist/cli/commands/assistants/index.d.ts.map +1 -0
  174. package/dist/cli/commands/assistants/index.js +28 -0
  175. package/dist/cli/commands/assistants/index.js.map +1 -0
  176. package/dist/cli/commands/assistants/list.d.ts +11 -0
  177. package/dist/cli/commands/assistants/list.d.ts.map +1 -0
  178. package/dist/cli/commands/assistants/list.js +323 -0
  179. package/dist/cli/commands/assistants/list.js.map +1 -0
  180. package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts +5 -0
  181. package/dist/cli/commands/doctor/checks/AgentsCheck.d.ts.map +1 -1
  182. package/dist/cli/commands/doctor/checks/AgentsCheck.js +29 -0
  183. package/dist/cli/commands/doctor/checks/AgentsCheck.js.map +1 -1
  184. package/dist/cli/commands/install.d.ts.map +1 -1
  185. package/dist/cli/commands/install.js +104 -13
  186. package/dist/cli/commands/install.js.map +1 -1
  187. package/dist/cli/commands/opencode-metrics.d.ts +13 -0
  188. package/dist/cli/commands/opencode-metrics.d.ts.map +1 -0
  189. package/dist/cli/commands/opencode-metrics.js +200 -0
  190. package/dist/cli/commands/opencode-metrics.js.map +1 -0
  191. package/dist/cli/commands/self-update.d.ts +3 -0
  192. package/dist/cli/commands/self-update.d.ts.map +1 -0
  193. package/dist/cli/commands/self-update.js +55 -0
  194. package/dist/cli/commands/self-update.js.map +1 -0
  195. package/dist/cli/commands/setup.d.ts.map +1 -1
  196. package/dist/cli/commands/setup.js +113 -0
  197. package/dist/cli/commands/setup.js.map +1 -1
  198. package/dist/cli/commands/skill.d.ts +6 -0
  199. package/dist/cli/commands/skill.d.ts.map +1 -0
  200. package/dist/cli/commands/skill.js +196 -0
  201. package/dist/cli/commands/skill.js.map +1 -0
  202. package/dist/cli/commands/update.d.ts.map +1 -1
  203. package/dist/cli/commands/update.js +34 -6
  204. package/dist/cli/commands/update.js.map +1 -1
  205. package/dist/cli/index.d.ts.map +1 -1
  206. package/dist/cli/index.js +12 -4
  207. package/dist/cli/index.js.map +1 -1
  208. package/dist/env/types.d.ts +13 -0
  209. package/dist/env/types.d.ts.map +1 -1
  210. package/dist/env/types.js +1 -1
  211. package/dist/env/types.js.map +1 -1
  212. package/dist/migrations/003-remove-hooks-node.migration.d.ts +22 -0
  213. package/dist/migrations/003-remove-hooks-node.migration.d.ts.map +1 -0
  214. package/dist/migrations/003-remove-hooks-node.migration.js +103 -0
  215. package/dist/migrations/003-remove-hooks-node.migration.js.map +1 -0
  216. package/dist/migrations/index.d.ts +1 -0
  217. package/dist/migrations/index.d.ts.map +1 -1
  218. package/dist/migrations/index.js +1 -1
  219. package/dist/migrations/index.js.map +1 -1
  220. package/dist/providers/plugins/sso/sso.http-client.js +2 -2
  221. package/dist/providers/plugins/sso/sso.http-client.js.map +1 -1
  222. package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
  223. package/dist/providers/plugins/sso/sso.setup-steps.js +14 -10
  224. package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
  225. package/dist/skills/core/SkillDiscovery.d.ts +83 -0
  226. package/dist/skills/core/SkillDiscovery.d.ts.map +1 -0
  227. package/dist/skills/core/SkillDiscovery.js +237 -0
  228. package/dist/skills/core/SkillDiscovery.js.map +1 -0
  229. package/dist/skills/core/SkillManager.d.ts +86 -0
  230. package/dist/skills/core/SkillManager.d.ts.map +1 -0
  231. package/dist/skills/core/SkillManager.js +155 -0
  232. package/dist/skills/core/SkillManager.js.map +1 -0
  233. package/dist/skills/core/types.d.ts +120 -0
  234. package/dist/skills/core/types.d.ts.map +1 -0
  235. package/dist/skills/core/types.js +20 -0
  236. package/dist/skills/core/types.js.map +1 -0
  237. package/dist/skills/index.d.ts +12 -0
  238. package/dist/skills/index.d.ts.map +1 -0
  239. package/dist/skills/index.js +12 -0
  240. package/dist/skills/index.js.map +1 -0
  241. package/dist/skills/utils/content-loader.d.ts +25 -0
  242. package/dist/skills/utils/content-loader.d.ts.map +1 -0
  243. package/dist/skills/utils/content-loader.js +161 -0
  244. package/dist/skills/utils/content-loader.js.map +1 -0
  245. package/dist/skills/utils/frontmatter.d.ts +60 -0
  246. package/dist/skills/utils/frontmatter.d.ts.map +1 -0
  247. package/dist/skills/utils/frontmatter.js +114 -0
  248. package/dist/skills/utils/frontmatter.js.map +1 -0
  249. package/dist/skills/utils/pattern-matcher.d.ts +60 -0
  250. package/dist/skills/utils/pattern-matcher.d.ts.map +1 -0
  251. package/dist/skills/utils/pattern-matcher.js +97 -0
  252. package/dist/skills/utils/pattern-matcher.js.map +1 -0
  253. package/dist/utils/auth.d.ts +22 -0
  254. package/dist/utils/auth.d.ts.map +1 -0
  255. package/dist/utils/auth.js +50 -0
  256. package/dist/utils/auth.js.map +1 -0
  257. package/dist/utils/cli-updater.d.ts +70 -0
  258. package/dist/utils/cli-updater.d.ts.map +1 -0
  259. package/dist/utils/cli-updater.js +339 -0
  260. package/dist/utils/cli-updater.js.map +1 -0
  261. package/dist/utils/config.d.ts +6 -1
  262. package/dist/utils/config.d.ts.map +1 -1
  263. package/dist/utils/config.js +13 -0
  264. package/dist/utils/config.js.map +1 -1
  265. package/dist/utils/installation-detector.d.ts +22 -0
  266. package/dist/utils/installation-detector.d.ts.map +1 -0
  267. package/dist/utils/installation-detector.js +49 -0
  268. package/dist/utils/installation-detector.js.map +1 -0
  269. package/dist/utils/native-installer.d.ts +49 -0
  270. package/dist/utils/native-installer.d.ts.map +1 -0
  271. package/dist/utils/native-installer.js +225 -0
  272. package/dist/utils/native-installer.js.map +1 -0
  273. package/dist/utils/processes.js +1 -1
  274. package/dist/utils/profile.d.ts +2 -0
  275. package/dist/utils/profile.d.ts.map +1 -1
  276. package/dist/utils/profile.js +5 -0
  277. package/dist/utils/profile.js.map +1 -1
  278. package/dist/utils/sdk-client.d.ts +15 -0
  279. package/dist/utils/sdk-client.d.ts.map +1 -0
  280. package/dist/utils/sdk-client.js +92 -0
  281. package/dist/utils/sdk-client.js.map +1 -0
  282. package/dist/utils/version-utils.d.ts +50 -0
  283. package/dist/utils/version-utils.d.ts.map +1 -0
  284. package/dist/utils/version-utils.js +92 -0
  285. package/dist/utils/version-utils.js.map +1 -0
  286. package/package.json +11 -3
  287. package/scripts/copy-mr-skill-to-global.ts +252 -0
  288. package/scripts/demo-hooks.sh +125 -0
  289. package/scripts/test-hooks.sh +196 -0
  290. package/dist/agents/plugins/claude/plugin/claude-templates/templates/INDEX.md +0 -205
  291. package/dist/agents/plugins/claude/plugin/claude-templates/templates/TEMPLATE_SIZES.md +0 -74
  292. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/layered-architecture.md.template +0 -143
  293. package/dist/agents/plugins/claude/plugin/claude-templates/templates/guides/architecture/project-structure.md.template +0 -127
  294. package/dist/agents/plugins/claude/plugin/commands/codemie-pr.md +0 -25
@@ -0,0 +1,116 @@
1
+ import { isTextPart, isToolPart, isFilePart, isReasoningPart } from '../../opencode-message-types.js';
2
+ import { logger } from '../../../../../utils/logger.js';
3
+ /**
4
+ * OpenCode Conversations Processor
5
+ *
6
+ * Normalizes OpenCode messages and parts into unified conversation format.
7
+ * Implements SessionProcessor interface for processor chain.
8
+ */
9
+ export class OpenCodeConversationsProcessor {
10
+ name = 'opencode-conversations';
11
+ priority = 2; // Run after metrics
12
+ /**
13
+ * Check if session has data to process
14
+ */
15
+ shouldProcess(session) {
16
+ return session.messages.length > 0;
17
+ }
18
+ /**
19
+ * Process session to normalize conversations
20
+ */
21
+ async process(session, _context) {
22
+ try {
23
+ const messages = session.messages;
24
+ const normalizedMessages = [];
25
+ for (const message of messages) {
26
+ // UPDATED (GPT-5.9): Use time.created (numeric) instead of createdAt (string)
27
+ // For full implementation, parts would be loaded from part/{messageId}/*.json
28
+ // For now, create basic normalized message from message data
29
+ const normalized = {
30
+ id: message.id,
31
+ role: message.role,
32
+ content: '', // Would be populated from text parts (AC-EXT-1)
33
+ // UPDATED (GPT-5.9): Convert numeric timestamp to ISO string
34
+ timestamp: message.time?.created
35
+ ? new Date(message.time.created).toISOString()
36
+ : new Date().toISOString(),
37
+ // UPDATED (GPT-5.9): modelID is on assistant messages only
38
+ model: message.role === 'assistant'
39
+ ? message.modelID
40
+ : undefined,
41
+ agent: message.role === 'assistant'
42
+ ? message.agent
43
+ : undefined
44
+ };
45
+ normalizedMessages.push(normalized);
46
+ }
47
+ logger.debug(`[opencode-conversations] Normalized ${normalizedMessages.length} messages`);
48
+ return {
49
+ success: true,
50
+ message: `Normalized ${normalizedMessages.length} messages`,
51
+ metadata: {
52
+ recordsProcessed: normalizedMessages.length,
53
+ userMessages: normalizedMessages.filter(m => m.role === 'user').length,
54
+ assistantMessages: normalizedMessages.filter(m => m.role === 'assistant').length
55
+ }
56
+ };
57
+ }
58
+ catch (error) {
59
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
60
+ logger.error(`[opencode-conversations] Processing failed:`, error);
61
+ return {
62
+ success: false,
63
+ message: `Conversations processing failed: ${errorMessage}`
64
+ };
65
+ }
66
+ }
67
+ /**
68
+ * Process parts for a message (helper for full implementation)
69
+ * Parts are loaded from part/{messageID}/*.json
70
+ *
71
+ * UPDATED (GPT-5.9): Use new part schema:
72
+ * - Tool parts: callID, tool, state.input, state (not toolName, toolInput, toolOutput)
73
+ * - File parts: mime, url, source, filename (not filePath, content)
74
+ */
75
+ processParts(parts) {
76
+ const textParts = [];
77
+ const toolUse = [];
78
+ const fileReferences = [];
79
+ const thinkingParts = [];
80
+ for (const part of parts) {
81
+ // Use type guards for safe narrowing
82
+ if (isTextPart(part)) {
83
+ textParts.push(part.text);
84
+ }
85
+ else if (isToolPart(part)) {
86
+ // UPDATED (GPT-5.9): New tool part schema
87
+ toolUse.push({
88
+ name: part.tool, // Was: part.toolName
89
+ input: part.state.input || {}, // Input is inside state
90
+ output: part.state?.output // Was: part.toolOutput
91
+ });
92
+ }
93
+ else if (isFilePart(part)) {
94
+ // UPDATED (GPT-5.9): New file part schema
95
+ // Use url or construct reference from filename
96
+ if (part.url) {
97
+ fileReferences.push(part.url);
98
+ }
99
+ else if (part.filename) {
100
+ fileReferences.push(part.filename);
101
+ }
102
+ }
103
+ else if (isReasoningPart(part)) {
104
+ thinkingParts.push(part.text);
105
+ }
106
+ // step-finish parts are skipped (metadata only - tokens/cost handled by metrics)
107
+ }
108
+ return {
109
+ content: textParts.join('\n'),
110
+ toolUse: toolUse.length > 0 ? toolUse : undefined,
111
+ fileReferences: fileReferences.length > 0 ? fileReferences : [],
112
+ thinking: thinkingParts.join('\n')
113
+ };
114
+ }
115
+ }
116
+ //# sourceMappingURL=opencode.conversations-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.conversations-processor.js","sourceRoot":"","sources":["../../../../../../src/agents/plugins/opencode/session/processors/opencode.conversations-processor.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAyBxD;;;;;GAKG;AACH,MAAM,OAAO,8BAA8B;IAChC,IAAI,GAAG,wBAAwB,CAAC;IAChC,QAAQ,GAAG,CAAC,CAAC,CAAE,oBAAoB;IAE5C;;OAEG;IACH,aAAa,CAAC,OAAsB;QAClC,OAAO,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,OAAsB,EAAE,QAA2B;QAC/D,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,OAAO,CAAC,QAA6B,CAAC;YACvD,MAAM,kBAAkB,GAAwB,EAAE,CAAC;YAEnD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,8EAA8E;gBAC9E,8EAA8E;gBAC9E,6DAA6D;gBAC7D,MAAM,UAAU,GAAsB;oBACpC,EAAE,EAAE,OAAO,CAAC,EAAE;oBACd,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,OAAO,EAAE,EAAE,EAAG,gDAAgD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C,IAAI,CAAC,CAAC;YAChC,CAAC;YACD,iFAAiF;QACnF,CAAC;QAED,OAAO;YACL,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YAC7B,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;YACjD,cAAc,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;YAC/D,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;SACnC,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * OpenCode Metrics Processor
3
+ *
4
+ * Transforms OpenCode session messages into MetricDelta records and writes
5
+ * them to JSONL for eventual sync to CodeMie API.
6
+ *
7
+ * Per tech spec "Fix OpenCode Metrics Sync":
8
+ * - Loads parts from storage/part/{messageID}/
9
+ * - Extracts tool usage, file operations, user prompts
10
+ * - Creates MetricDelta records per assistant message (ADR-16)
11
+ * - Writes to JSONL via MetricsWriter with status: 'pending'
12
+ * - Implements deduplication to prevent duplicate deltas
13
+ */
14
+ import type { SessionProcessor, ProcessingContext, ProcessingResult } from '../../../../core/session/BaseProcessor.js';
15
+ import type { ParsedSession } from '../../../../core/session/BaseSessionAdapter.js';
16
+ /**
17
+ * OpenCode Metrics Processor
18
+ *
19
+ * Aggregates token usage, extracts tool/file metrics from parts,
20
+ * and writes MetricDelta records to JSONL.
21
+ */
22
+ export declare class OpenCodeMetricsProcessor implements SessionProcessor {
23
+ readonly name = "opencode-metrics";
24
+ readonly priority = 1;
25
+ private readonly cacheDir;
26
+ constructor();
27
+ /**
28
+ * Check if session has data to process
29
+ */
30
+ shouldProcess(session: ParsedSession): boolean;
31
+ /**
32
+ * Process session to aggregate metrics and write JSONL deltas
33
+ *
34
+ * Per tech spec ADR-1/G2: Validate metadata at START before any processing
35
+ */
36
+ process(session: ParsedSession, _context: ProcessingContext): Promise<ProcessingResult>;
37
+ /**
38
+ * Check if session should be processed (cooldown check per ADR-18)
39
+ */
40
+ private shouldProcessSession;
41
+ /**
42
+ * Mark session as processed (ADR-18)
43
+ */
44
+ private markSessionProcessed;
45
+ /**
46
+ * Transform messages to MetricDelta records
47
+ *
48
+ * Per ADR-16: One delta per assistant message with tokens
49
+ */
50
+ private transformMessagesToDeltas;
51
+ /**
52
+ * Resolve token source with fallback (ADR-13)
53
+ */
54
+ private resolveTokenSource;
55
+ /**
56
+ * Resolve timestamp with fallback chain (ADR-13 G4)
57
+ */
58
+ private resolveTimestamp;
59
+ /**
60
+ * Load parts for a message (ADR-11 - part-message validation)
61
+ */
62
+ private loadPartsForMessage;
63
+ /**
64
+ * Extract tool metrics from parts (ADR-8, ADR-14)
65
+ */
66
+ private extractToolMetrics;
67
+ /**
68
+ * Map tool status to success/failure/skip (ADR-14)
69
+ */
70
+ private mapToolStatus;
71
+ /**
72
+ * Extract file operation from tool call (ADR-8, ADR-17)
73
+ * Only emits allowed file operation types.
74
+ */
75
+ private extractFileOperation;
76
+ /**
77
+ * Extract user prompts from messages (ADR-10, ADR-20)
78
+ */
79
+ private extractUserPrompts;
80
+ /**
81
+ * Extract user prompt text from message (ADR-10, ADR-20)
82
+ */
83
+ private extractUserPromptText;
84
+ /**
85
+ * Get existing record IDs for deduplication (ADR-5)
86
+ * Uses tolerant JSONL reading to handle corrupted lines.
87
+ */
88
+ private getExistingRecordIds;
89
+ /**
90
+ * Read existing deltas from JSONL file (ADR-5, ADR-21)
91
+ */
92
+ private readExistingDeltas;
93
+ /**
94
+ * Get valid model string (ADR-6)
95
+ */
96
+ private getValidModelString;
97
+ /**
98
+ * Update session.metrics for backward compatibility
99
+ */
100
+ private updateSessionMetrics;
101
+ }
102
+ //# sourceMappingURL=opencode.metrics-processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode.metrics-processor.d.ts","sourceRoot":"","sources":["../../../../../../src/agents/plugins/opencode/session/processors/opencode.metrics-processor.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AACvH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAkCpF;;;;;GAKG;AACH,qBAAa,wBAAyB,YAAW,gBAAgB;IAC/D,QAAQ,CAAC,IAAI,sBAAsB;IACnC,QAAQ,CAAC,QAAQ,KAAK;IAEtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;;IAMlC;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;IAI9C;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqH7F;;OAEG;YACW,oBAAoB;IAkBlC;;OAEG;YACW,oBAAoB;IAalC;;;;OAIG;YACW,yBAAyB;IA2HvC;;OAEG;YACW,kBAAkB;IAiChC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAuBxB;;OAEG;YACW,mBAAmB;IA2CjC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAiD1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAerB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IA+F5B;;OAEG;YACW,kBAAkB;IAmBhC;;OAEG;YACW,qBAAqB;IAsCnC;;;OAGG;YACW,oBAAoB;IAUlC;;OAEG;YACW,kBAAkB;IAiBhC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAmC7B"}