claude-code-workflow 6.3.18 → 6.3.20

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 (832) hide show
  1. package/.claude/CLAUDE.md +8 -5
  2. package/.claude/agents/action-planning-agent.md +26 -2
  3. package/.claude/agents/code-developer.md +132 -43
  4. package/.claude/agents/debug-explore-agent.md +434 -0
  5. package/.claude/agents/issue-plan-agent.md +31 -2
  6. package/.claude/agents/test-fix-agent.md +14 -0
  7. package/.claude/commands/issue/discover.md +41 -0
  8. package/.claude/commands/issue/execute.md +200 -19
  9. package/.claude/commands/issue/new.md +93 -3
  10. package/.claude/commands/issue/plan.md +9 -3
  11. package/.claude/commands/issue/queue.md +94 -39
  12. package/.claude/commands/memory/swagger-docs.md +773 -0
  13. package/.claude/commands/workflow/brainstorm/auto-parallel.md +21 -21
  14. package/.claude/commands/workflow/execute.md +54 -34
  15. package/.claude/commands/workflow/lite-execute.md +48 -164
  16. package/.claude/commands/workflow/lite-fix.md +4 -4
  17. package/.claude/commands/workflow/lite-plan.md +5 -5
  18. package/.claude/commands/workflow/plan.md +27 -27
  19. package/.claude/commands/workflow/review.md +42 -17
  20. package/.claude/commands/workflow/tdd-plan.md +25 -25
  21. package/.claude/commands/workflow/test-fix-gen.md +10 -10
  22. package/.claude/commands/workflow/test-gen.md +14 -14
  23. package/.claude/commands/workflow/ui-design/explore-auto.md +21 -21
  24. package/.claude/commands/workflow/ui-design/imitate-auto.md +24 -24
  25. package/.claude/skills/_shared/SKILL-DESIGN-SPEC.md +693 -0
  26. package/.claude/skills/ccw/SKILL.md +462 -0
  27. package/.claude/skills/ccw/index/command-capabilities.json +127 -0
  28. package/.claude/skills/ccw/index/intent-rules.json +136 -0
  29. package/.claude/skills/ccw/index/workflow-chains.json +451 -0
  30. package/.claude/skills/ccw/phases/actions/bugfix.md +218 -0
  31. package/.claude/skills/ccw/phases/actions/coupled.md +194 -0
  32. package/.claude/skills/ccw/phases/actions/docs.md +93 -0
  33. package/.claude/skills/ccw/phases/actions/full.md +154 -0
  34. package/.claude/skills/ccw/phases/actions/issue.md +201 -0
  35. package/.claude/skills/ccw/phases/actions/rapid.md +104 -0
  36. package/.claude/skills/ccw/phases/actions/review-fix.md +84 -0
  37. package/.claude/skills/ccw/phases/actions/tdd.md +66 -0
  38. package/.claude/skills/ccw/phases/actions/ui.md +79 -0
  39. package/.claude/skills/ccw/phases/orchestrator.md +435 -0
  40. package/.claude/skills/ccw/specs/intent-classification.md +336 -0
  41. package/.claude/skills/ccw-help/SKILL.md +177 -0
  42. package/.claude/skills/ccw-help/index/all-agents.json +82 -0
  43. package/.claude/skills/{command-guide → ccw-help}/index/all-commands.json +183 -73
  44. package/.claude/skills/{command-guide → ccw-help}/index/by-category.json +187 -73
  45. package/.claude/skills/{command-guide → ccw-help}/index/by-use-case.json +295 -185
  46. package/.claude/skills/{command-guide → ccw-help}/index/command-relationships.json +19 -166
  47. package/.claude/skills/{command-guide → ccw-help}/index/essential-commands.json +10 -10
  48. package/.claude/skills/ccw-help/scripts/analyze_commands.py +337 -0
  49. package/.claude/skills/code-reviewer/README.md +340 -0
  50. package/.claude/skills/code-reviewer/SKILL.md +308 -0
  51. package/.claude/skills/code-reviewer/phases/01-code-discovery.md +246 -0
  52. package/.claude/skills/code-reviewer/phases/02-security-analysis.md +442 -0
  53. package/.claude/skills/code-reviewer/phases/03-best-practices-review.md +36 -0
  54. package/.claude/skills/code-reviewer/phases/04-report-generation.md +278 -0
  55. package/.claude/skills/code-reviewer/specs/best-practices-requirements.md +346 -0
  56. package/.claude/skills/code-reviewer/specs/quality-standards.md +252 -0
  57. package/.claude/skills/code-reviewer/specs/security-requirements.md +243 -0
  58. package/.claude/skills/code-reviewer/templates/best-practice-finding.md +234 -0
  59. package/.claude/skills/code-reviewer/templates/report-template.md +316 -0
  60. package/.claude/skills/code-reviewer/templates/security-finding.md +161 -0
  61. package/.claude/skills/skill-generator/SKILL.md +187 -0
  62. package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +239 -0
  63. package/.claude/skills/skill-generator/phases/02-structure-generation.md +207 -0
  64. package/.claude/skills/skill-generator/phases/03-phase-generation.md +802 -0
  65. package/.claude/skills/skill-generator/phases/04-specs-templates.md +328 -0
  66. package/.claude/skills/skill-generator/phases/05-validation.md +334 -0
  67. package/.claude/skills/skill-generator/specs/cli-integration.md +448 -0
  68. package/.claude/skills/skill-generator/specs/execution-modes.md +396 -0
  69. package/.claude/skills/skill-generator/specs/scripting-integration.md +265 -0
  70. package/.claude/skills/skill-generator/specs/skill-requirements.md +466 -0
  71. package/.claude/skills/skill-generator/templates/autonomous-action.md +517 -0
  72. package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +276 -0
  73. package/.claude/skills/skill-generator/templates/code-analysis-action.md +503 -0
  74. package/.claude/skills/skill-generator/templates/llm-action.md +355 -0
  75. package/.claude/skills/skill-generator/templates/script-bash.md +277 -0
  76. package/.claude/skills/skill-generator/templates/script-python.md +198 -0
  77. package/.claude/skills/skill-generator/templates/sequential-phase.md +441 -0
  78. package/.claude/skills/skill-generator/templates/skill-md.md +156 -0
  79. package/.claude/workflows/chinese-response.md +15 -28
  80. package/.claude/workflows/cli-templates/prompts/documentation/swagger-api.txt +266 -0
  81. package/.claude/workflows/cli-tools-usage.md +221 -177
  82. package/.claude/workflows/windows-platform.md +13 -10
  83. package/.codex/prompts/issue-execute.md +310 -82
  84. package/.codex/prompts/issue-queue.md +22 -0
  85. package/.codex/prompts/lite-execute.md +36 -11
  86. package/README.md +309 -305
  87. package/ccw/README.md +10 -4
  88. package/ccw/dist/cli.d.ts.map +1 -1
  89. package/ccw/dist/cli.js +4 -1
  90. package/ccw/dist/cli.js.map +1 -1
  91. package/ccw/dist/commands/cli.d.ts.map +1 -1
  92. package/ccw/dist/commands/cli.js +131 -34
  93. package/ccw/dist/commands/cli.js.map +1 -1
  94. package/ccw/dist/commands/issue.d.ts +152 -0
  95. package/ccw/dist/commands/issue.d.ts.map +1 -1
  96. package/ccw/dist/commands/issue.js +550 -85
  97. package/ccw/dist/commands/issue.js.map +1 -1
  98. package/ccw/dist/commands/serve.d.ts +1 -0
  99. package/ccw/dist/commands/serve.d.ts.map +1 -1
  100. package/ccw/dist/commands/serve.js +12 -5
  101. package/ccw/dist/commands/serve.js.map +1 -1
  102. package/ccw/dist/commands/stop.d.ts.map +1 -1
  103. package/ccw/dist/commands/stop.js +29 -5
  104. package/ccw/dist/commands/stop.js.map +1 -1
  105. package/ccw/dist/commands/tool.d.ts.map +1 -1
  106. package/ccw/dist/commands/tool.js +19 -2
  107. package/ccw/dist/commands/tool.js.map +1 -1
  108. package/ccw/dist/commands/view.d.ts +1 -0
  109. package/ccw/dist/commands/view.d.ts.map +1 -1
  110. package/ccw/dist/commands/view.js +10 -3
  111. package/ccw/dist/commands/view.js.map +1 -1
  112. package/ccw/dist/config/cli-settings-manager.d.ts +86 -0
  113. package/ccw/dist/config/cli-settings-manager.d.ts.map +1 -0
  114. package/ccw/dist/config/cli-settings-manager.js +392 -0
  115. package/ccw/dist/config/cli-settings-manager.js.map +1 -0
  116. package/ccw/dist/config/litellm-api-config-manager.d.ts +71 -5
  117. package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
  118. package/ccw/dist/config/litellm-api-config-manager.js +290 -20
  119. package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
  120. package/ccw/dist/core/auth/csrf-manager.d.ts +18 -0
  121. package/ccw/dist/core/auth/csrf-manager.d.ts.map +1 -0
  122. package/ccw/dist/core/auth/csrf-manager.js +80 -0
  123. package/ccw/dist/core/auth/csrf-manager.js.map +1 -0
  124. package/ccw/dist/core/auth/csrf-middleware.d.ts +8 -0
  125. package/ccw/dist/core/auth/csrf-middleware.d.ts.map +1 -0
  126. package/ccw/dist/core/auth/csrf-middleware.js +141 -0
  127. package/ccw/dist/core/auth/csrf-middleware.js.map +1 -0
  128. package/ccw/dist/core/auth/middleware.d.ts +15 -0
  129. package/ccw/dist/core/auth/middleware.d.ts.map +1 -0
  130. package/ccw/dist/core/auth/middleware.js +76 -0
  131. package/ccw/dist/core/auth/middleware.js.map +1 -0
  132. package/ccw/dist/core/auth/token-manager.d.ts +41 -0
  133. package/ccw/dist/core/auth/token-manager.d.ts.map +1 -0
  134. package/ccw/dist/core/auth/token-manager.js +171 -0
  135. package/ccw/dist/core/auth/token-manager.js.map +1 -0
  136. package/ccw/dist/core/cache-manager.d.ts +6 -6
  137. package/ccw/dist/core/cache-manager.d.ts.map +1 -1
  138. package/ccw/dist/core/cache-manager.js +70 -48
  139. package/ccw/dist/core/cache-manager.js.map +1 -1
  140. package/ccw/dist/core/claude-freshness.d.ts.map +1 -1
  141. package/ccw/dist/core/claude-freshness.js +23 -3
  142. package/ccw/dist/core/claude-freshness.js.map +1 -1
  143. package/ccw/dist/core/core-memory-store.d.ts.map +1 -1
  144. package/ccw/dist/core/core-memory-store.js +2 -1
  145. package/ccw/dist/core/core-memory-store.js.map +1 -1
  146. package/ccw/dist/core/cors.d.ts +3 -0
  147. package/ccw/dist/core/cors.d.ts.map +1 -0
  148. package/ccw/dist/core/cors.js +10 -0
  149. package/ccw/dist/core/cors.js.map +1 -0
  150. package/ccw/dist/core/dashboard-generator-patch.js +0 -1
  151. package/ccw/dist/core/dashboard-generator-patch.js.map +1 -1
  152. package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
  153. package/ccw/dist/core/dashboard-generator.js +417 -416
  154. package/ccw/dist/core/dashboard-generator.js.map +1 -1
  155. package/ccw/dist/core/data-aggregator.js +2 -2
  156. package/ccw/dist/core/data-aggregator.js.map +1 -1
  157. package/ccw/dist/core/lite-scanner.d.ts +1 -1
  158. package/ccw/dist/core/lite-scanner.d.ts.map +1 -1
  159. package/ccw/dist/core/lite-scanner.js +130 -127
  160. package/ccw/dist/core/lite-scanner.js.map +1 -1
  161. package/ccw/dist/core/routes/auth-routes.d.ts +12 -0
  162. package/ccw/dist/core/routes/auth-routes.d.ts.map +1 -0
  163. package/ccw/dist/core/routes/auth-routes.js +80 -0
  164. package/ccw/dist/core/routes/auth-routes.js.map +1 -0
  165. package/ccw/dist/core/routes/ccw-routes.d.ts +1 -14
  166. package/ccw/dist/core/routes/ccw-routes.d.ts.map +1 -1
  167. package/ccw/dist/core/routes/ccw-routes.js +9 -4
  168. package/ccw/dist/core/routes/ccw-routes.js.map +1 -1
  169. package/ccw/dist/core/routes/claude-routes.d.ts +1 -14
  170. package/ccw/dist/core/routes/claude-routes.d.ts.map +1 -1
  171. package/ccw/dist/core/routes/claude-routes.js +98 -39
  172. package/ccw/dist/core/routes/claude-routes.js.map +1 -1
  173. package/ccw/dist/core/routes/cli-routes.d.ts +14 -12
  174. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  175. package/ccw/dist/core/routes/cli-routes.js +122 -43
  176. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  177. package/ccw/dist/core/routes/cli-settings-routes.d.ts +11 -0
  178. package/ccw/dist/core/routes/cli-settings-routes.d.ts.map +1 -0
  179. package/ccw/dist/core/routes/cli-settings-routes.js +204 -0
  180. package/ccw/dist/core/routes/cli-settings-routes.js.map +1 -0
  181. package/ccw/dist/core/routes/codexlens/config-handlers.d.ts +6 -0
  182. package/ccw/dist/core/routes/codexlens/config-handlers.d.ts.map +1 -0
  183. package/ccw/dist/core/routes/codexlens/config-handlers.js +1195 -0
  184. package/ccw/dist/core/routes/codexlens/config-handlers.js.map +1 -0
  185. package/ccw/dist/core/routes/codexlens/index-handlers.d.ts +10 -0
  186. package/ccw/dist/core/routes/codexlens/index-handlers.d.ts.map +1 -0
  187. package/ccw/dist/core/routes/codexlens/index-handlers.js +322 -0
  188. package/ccw/dist/core/routes/codexlens/index-handlers.js.map +1 -0
  189. package/ccw/dist/core/routes/codexlens/semantic-handlers.d.ts +6 -0
  190. package/ccw/dist/core/routes/codexlens/semantic-handlers.d.ts.map +1 -0
  191. package/ccw/dist/core/routes/codexlens/semantic-handlers.js +865 -0
  192. package/ccw/dist/core/routes/codexlens/semantic-handlers.js.map +1 -0
  193. package/ccw/dist/core/routes/codexlens/utils.d.ts +23 -0
  194. package/ccw/dist/core/routes/codexlens/utils.d.ts.map +1 -0
  195. package/ccw/dist/core/routes/codexlens/utils.js +85 -0
  196. package/ccw/dist/core/routes/codexlens/utils.js.map +1 -0
  197. package/ccw/dist/core/routes/codexlens/watcher-handlers.d.ts +13 -0
  198. package/ccw/dist/core/routes/codexlens/watcher-handlers.d.ts.map +1 -0
  199. package/ccw/dist/core/routes/codexlens/watcher-handlers.js +235 -0
  200. package/ccw/dist/core/routes/codexlens/watcher-handlers.js.map +1 -0
  201. package/ccw/dist/core/routes/codexlens-routes.d.ts +2 -11
  202. package/ccw/dist/core/routes/codexlens-routes.d.ts.map +1 -1
  203. package/ccw/dist/core/routes/codexlens-routes.js +10 -981
  204. package/ccw/dist/core/routes/codexlens-routes.js.map +1 -1
  205. package/ccw/dist/core/routes/discovery-routes.d.ts +1 -35
  206. package/ccw/dist/core/routes/discovery-routes.d.ts.map +1 -1
  207. package/ccw/dist/core/routes/discovery-routes.js +25 -0
  208. package/ccw/dist/core/routes/discovery-routes.js.map +1 -1
  209. package/ccw/dist/core/routes/files-routes.d.ts +1 -14
  210. package/ccw/dist/core/routes/files-routes.d.ts.map +1 -1
  211. package/ccw/dist/core/routes/files-routes.js +57 -14
  212. package/ccw/dist/core/routes/files-routes.js.map +1 -1
  213. package/ccw/dist/core/routes/graph-routes.d.ts +1 -14
  214. package/ccw/dist/core/routes/graph-routes.d.ts.map +1 -1
  215. package/ccw/dist/core/routes/graph-routes.js +36 -37
  216. package/ccw/dist/core/routes/graph-routes.js.map +1 -1
  217. package/ccw/dist/core/routes/help-routes.d.ts +1 -14
  218. package/ccw/dist/core/routes/help-routes.d.ts.map +1 -1
  219. package/ccw/dist/core/routes/help-routes.js +5 -0
  220. package/ccw/dist/core/routes/help-routes.js.map +1 -1
  221. package/ccw/dist/core/routes/hooks-routes.d.ts +4 -14
  222. package/ccw/dist/core/routes/hooks-routes.d.ts.map +1 -1
  223. package/ccw/dist/core/routes/hooks-routes.js +43 -21
  224. package/ccw/dist/core/routes/hooks-routes.js.map +1 -1
  225. package/ccw/dist/core/routes/issue-routes.d.ts +1 -34
  226. package/ccw/dist/core/routes/issue-routes.d.ts.map +1 -1
  227. package/ccw/dist/core/routes/issue-routes.js +24 -0
  228. package/ccw/dist/core/routes/issue-routes.js.map +1 -1
  229. package/ccw/dist/core/routes/litellm-api-routes.d.ts +1 -14
  230. package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -1
  231. package/ccw/dist/core/routes/litellm-api-routes.js +513 -48
  232. package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -1
  233. package/ccw/dist/core/routes/litellm-routes.d.ts +1 -14
  234. package/ccw/dist/core/routes/litellm-routes.d.ts.map +1 -1
  235. package/ccw/dist/core/routes/litellm-routes.js +28 -11
  236. package/ccw/dist/core/routes/litellm-routes.js.map +1 -1
  237. package/ccw/dist/core/routes/mcp-routes.d.ts +1 -14
  238. package/ccw/dist/core/routes/mcp-routes.d.ts.map +1 -1
  239. package/ccw/dist/core/routes/mcp-routes.js +99 -30
  240. package/ccw/dist/core/routes/mcp-routes.js.map +1 -1
  241. package/ccw/dist/core/routes/mcp-templates-db.d.ts.map +1 -1
  242. package/ccw/dist/core/routes/mcp-templates-db.js +30 -31
  243. package/ccw/dist/core/routes/mcp-templates-db.js.map +1 -1
  244. package/ccw/dist/core/routes/memory-routes.d.ts.map +1 -1
  245. package/ccw/dist/core/routes/memory-routes.js +74 -24
  246. package/ccw/dist/core/routes/memory-routes.js.map +1 -1
  247. package/ccw/dist/core/routes/nav-status-routes.d.ts +3 -0
  248. package/ccw/dist/core/routes/nav-status-routes.d.ts.map +1 -0
  249. package/ccw/dist/core/routes/nav-status-routes.js +217 -0
  250. package/ccw/dist/core/routes/nav-status-routes.js.map +1 -0
  251. package/ccw/dist/core/routes/rules-routes.d.ts +1 -14
  252. package/ccw/dist/core/routes/rules-routes.d.ts.map +1 -1
  253. package/ccw/dist/core/routes/rules-routes.js +481 -58
  254. package/ccw/dist/core/routes/rules-routes.js.map +1 -1
  255. package/ccw/dist/core/routes/session-routes.d.ts +1 -14
  256. package/ccw/dist/core/routes/session-routes.d.ts.map +1 -1
  257. package/ccw/dist/core/routes/session-routes.js +15 -3
  258. package/ccw/dist/core/routes/session-routes.js.map +1 -1
  259. package/ccw/dist/core/routes/skills-routes.d.ts +1 -14
  260. package/ccw/dist/core/routes/skills-routes.d.ts.map +1 -1
  261. package/ccw/dist/core/routes/skills-routes.js +394 -112
  262. package/ccw/dist/core/routes/skills-routes.js.map +1 -1
  263. package/ccw/dist/core/routes/status-routes.d.ts +1 -14
  264. package/ccw/dist/core/routes/status-routes.d.ts.map +1 -1
  265. package/ccw/dist/core/routes/status-routes.js +4 -0
  266. package/ccw/dist/core/routes/status-routes.js.map +1 -1
  267. package/ccw/dist/core/routes/system-routes.d.ts +4 -10
  268. package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
  269. package/ccw/dist/core/routes/system-routes.js +6 -4
  270. package/ccw/dist/core/routes/system-routes.js.map +1 -1
  271. package/ccw/dist/core/routes/types.d.ts +19 -0
  272. package/ccw/dist/core/routes/types.d.ts.map +1 -0
  273. package/ccw/dist/core/routes/types.js +2 -0
  274. package/ccw/dist/core/routes/types.js.map +1 -0
  275. package/ccw/dist/core/server.d.ts.map +1 -1
  276. package/ccw/dist/core/server.js +206 -29
  277. package/ccw/dist/core/server.js.map +1 -1
  278. package/ccw/dist/core/services/api-key-tester.d.ts +42 -0
  279. package/ccw/dist/core/services/api-key-tester.d.ts.map +1 -0
  280. package/ccw/dist/core/services/api-key-tester.js +126 -0
  281. package/ccw/dist/core/services/api-key-tester.js.map +1 -0
  282. package/ccw/dist/core/services/health-check-service.d.ts +88 -0
  283. package/ccw/dist/core/services/health-check-service.d.ts.map +1 -0
  284. package/ccw/dist/core/services/health-check-service.js +293 -0
  285. package/ccw/dist/core/services/health-check-service.js.map +1 -0
  286. package/ccw/dist/core/websocket.d.ts +9 -7
  287. package/ccw/dist/core/websocket.d.ts.map +1 -1
  288. package/ccw/dist/core/websocket.js +9 -4
  289. package/ccw/dist/core/websocket.js.map +1 -1
  290. package/ccw/dist/tools/claude-cli-tools.d.ts +152 -28
  291. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  292. package/ccw/dist/tools/claude-cli-tools.js +490 -100
  293. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  294. package/ccw/dist/tools/cli-config-manager.d.ts +24 -8
  295. package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
  296. package/ccw/dist/tools/cli-config-manager.js +76 -156
  297. package/ccw/dist/tools/cli-config-manager.js.map +1 -1
  298. package/ccw/dist/tools/cli-executor-core.d.ts +85 -0
  299. package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -0
  300. package/ccw/dist/tools/cli-executor-core.js +1310 -0
  301. package/ccw/dist/tools/cli-executor-core.js.map +1 -0
  302. package/ccw/dist/tools/cli-executor-state.d.ts +241 -0
  303. package/ccw/dist/tools/cli-executor-state.d.ts.map +1 -0
  304. package/ccw/dist/tools/cli-executor-state.js +392 -0
  305. package/ccw/dist/tools/cli-executor-state.js.map +1 -0
  306. package/ccw/dist/tools/cli-executor-utils.d.ts +36 -0
  307. package/ccw/dist/tools/cli-executor-utils.d.ts.map +1 -0
  308. package/ccw/dist/tools/cli-executor-utils.js +298 -0
  309. package/ccw/dist/tools/cli-executor-utils.js.map +1 -0
  310. package/ccw/dist/tools/cli-executor.d.ts +3 -377
  311. package/ccw/dist/tools/cli-executor.d.ts.map +1 -1
  312. package/ccw/dist/tools/cli-executor.js +3 -1884
  313. package/ccw/dist/tools/cli-executor.js.map +1 -1
  314. package/ccw/dist/tools/cli-history-store.d.ts +2 -0
  315. package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
  316. package/ccw/dist/tools/cli-history-store.js.map +1 -1
  317. package/ccw/dist/tools/cli-output-converter.d.ts +192 -0
  318. package/ccw/dist/tools/cli-output-converter.d.ts.map +1 -0
  319. package/ccw/dist/tools/cli-output-converter.js +1047 -0
  320. package/ccw/dist/tools/cli-output-converter.js.map +1 -0
  321. package/ccw/dist/tools/cli-prompt-builder.d.ts +113 -0
  322. package/ccw/dist/tools/cli-prompt-builder.d.ts.map +1 -0
  323. package/ccw/dist/tools/cli-prompt-builder.js +363 -0
  324. package/ccw/dist/tools/cli-prompt-builder.js.map +1 -0
  325. package/ccw/dist/tools/codex-lens.d.ts +15 -1
  326. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  327. package/ccw/dist/tools/codex-lens.js +289 -55
  328. package/ccw/dist/tools/codex-lens.js.map +1 -1
  329. package/ccw/dist/tools/detect-changed-modules.d.ts.map +1 -1
  330. package/ccw/dist/tools/detect-changed-modules.js +22 -4
  331. package/ccw/dist/tools/detect-changed-modules.js.map +1 -1
  332. package/ccw/dist/tools/index.d.ts.map +1 -1
  333. package/ccw/dist/tools/index.js +2 -0
  334. package/ccw/dist/tools/index.js.map +1 -1
  335. package/ccw/dist/tools/litellm-client.d.ts.map +1 -1
  336. package/ccw/dist/tools/litellm-client.js +10 -4
  337. package/ccw/dist/tools/litellm-client.js.map +1 -1
  338. package/ccw/dist/tools/litellm-executor.d.ts +2 -4
  339. package/ccw/dist/tools/litellm-executor.d.ts.map +1 -1
  340. package/ccw/dist/tools/litellm-executor.js +39 -8
  341. package/ccw/dist/tools/litellm-executor.js.map +1 -1
  342. package/ccw/dist/tools/native-session-discovery.d.ts +2 -0
  343. package/ccw/dist/tools/native-session-discovery.d.ts.map +1 -1
  344. package/ccw/dist/tools/native-session-discovery.js +197 -1
  345. package/ccw/dist/tools/native-session-discovery.js.map +1 -1
  346. package/ccw/dist/tools/session-manager.d.ts.map +1 -1
  347. package/ccw/dist/tools/session-manager.js +79 -0
  348. package/ccw/dist/tools/session-manager.js.map +1 -1
  349. package/ccw/dist/tools/skill-context-loader.d.ts +15 -0
  350. package/ccw/dist/tools/skill-context-loader.d.ts.map +1 -0
  351. package/ccw/dist/tools/skill-context-loader.js +198 -0
  352. package/ccw/dist/tools/skill-context-loader.js.map +1 -0
  353. package/ccw/dist/tools/smart-search.d.ts +8 -3
  354. package/ccw/dist/tools/smart-search.d.ts.map +1 -1
  355. package/ccw/dist/tools/smart-search.js +378 -75
  356. package/ccw/dist/tools/smart-search.js.map +1 -1
  357. package/ccw/dist/types/cli-settings.d.ts +86 -0
  358. package/ccw/dist/types/cli-settings.d.ts.map +1 -0
  359. package/ccw/dist/types/cli-settings.js +54 -0
  360. package/ccw/dist/types/cli-settings.js.map +1 -0
  361. package/ccw/dist/types/litellm-api-config.d.ts +40 -1
  362. package/ccw/dist/types/litellm-api-config.d.ts.map +1 -1
  363. package/ccw/dist/utils/exec-constants.d.ts +25 -0
  364. package/ccw/dist/utils/exec-constants.d.ts.map +1 -0
  365. package/ccw/dist/utils/exec-constants.js +25 -0
  366. package/ccw/dist/utils/exec-constants.js.map +1 -0
  367. package/ccw/dist/utils/path-resolver.d.ts +1 -0
  368. package/ccw/dist/utils/path-resolver.d.ts.map +1 -1
  369. package/ccw/dist/utils/path-resolver.js +48 -3
  370. package/ccw/dist/utils/path-resolver.js.map +1 -1
  371. package/ccw/dist/utils/path-validator.d.ts.map +1 -1
  372. package/ccw/dist/utils/path-validator.js +25 -6
  373. package/ccw/dist/utils/path-validator.js.map +1 -1
  374. package/ccw/dist/utils/python-utils.d.ts.map +1 -1
  375. package/ccw/dist/utils/python-utils.js +27 -7
  376. package/ccw/dist/utils/python-utils.js.map +1 -1
  377. package/ccw/dist/utils/shell-escape.d.ts +8 -0
  378. package/ccw/dist/utils/shell-escape.d.ts.map +1 -0
  379. package/ccw/dist/utils/shell-escape.js +24 -0
  380. package/ccw/dist/utils/shell-escape.js.map +1 -0
  381. package/ccw/dist/utils/uv-manager.d.ts +167 -0
  382. package/ccw/dist/utils/uv-manager.d.ts.map +1 -0
  383. package/ccw/dist/utils/uv-manager.js +644 -0
  384. package/ccw/dist/utils/uv-manager.js.map +1 -0
  385. package/ccw/src/cli.ts +4 -1
  386. package/ccw/src/commands/cli.ts +132 -34
  387. package/ccw/src/commands/issue.ts +605 -91
  388. package/ccw/src/commands/serve.ts +15 -5
  389. package/ccw/src/commands/stop.ts +32 -5
  390. package/ccw/src/commands/tool.ts +17 -2
  391. package/ccw/src/commands/view.ts +13 -3
  392. package/ccw/src/config/cli-settings-manager.ts +460 -0
  393. package/ccw/src/config/litellm-api-config-manager.ts +392 -57
  394. package/ccw/src/core/auth/csrf-manager.ts +104 -0
  395. package/ccw/src/core/auth/csrf-middleware.ts +159 -0
  396. package/ccw/src/core/auth/middleware.ts +94 -0
  397. package/ccw/src/core/auth/token-manager.ts +219 -0
  398. package/ccw/src/core/cache-manager.ts +64 -52
  399. package/ccw/src/core/claude-freshness.ts +26 -6
  400. package/ccw/src/core/core-memory-store.ts +2 -1
  401. package/ccw/src/core/cors.ts +10 -0
  402. package/ccw/src/core/dashboard-generator-patch.ts +47 -48
  403. package/ccw/src/core/dashboard-generator.ts +797 -744
  404. package/ccw/src/core/data-aggregator.ts +667 -667
  405. package/ccw/src/core/lite-scanner.ts +156 -140
  406. package/ccw/src/core/routes/auth-routes.ts +98 -0
  407. package/ccw/src/core/routes/ccw-routes.ts +10 -20
  408. package/ccw/src/core/routes/claude-routes.ts +101 -51
  409. package/ccw/src/core/routes/cli-routes.ts +152 -55
  410. package/ccw/src/core/routes/cli-settings-routes.ts +232 -0
  411. package/ccw/src/core/routes/codexlens/README.md +37 -0
  412. package/ccw/src/core/routes/codexlens/config-handlers.ts +1269 -0
  413. package/ccw/src/core/routes/codexlens/index-handlers.ts +354 -0
  414. package/ccw/src/core/routes/codexlens/semantic-handlers.ts +931 -0
  415. package/ccw/src/core/routes/codexlens/utils.ts +96 -0
  416. package/ccw/src/core/routes/codexlens/watcher-handlers.ts +265 -0
  417. package/ccw/src/core/routes/codexlens-routes.ts +11 -1044
  418. package/ccw/src/core/routes/discovery-routes.ts +1 -12
  419. package/ccw/src/core/routes/files-routes.ts +112 -40
  420. package/ccw/src/core/routes/graph-routes.ts +39 -46
  421. package/ccw/src/core/routes/help-routes.ts +2 -12
  422. package/ccw/src/core/routes/hooks-routes.ts +83 -44
  423. package/ccw/src/core/routes/issue-routes.ts +1 -12
  424. package/ccw/src/core/routes/litellm-api-routes.ts +574 -60
  425. package/ccw/src/core/routes/litellm-routes.ts +35 -27
  426. package/ccw/src/core/routes/mcp-routes.ts +157 -60
  427. package/ccw/src/core/routes/mcp-routes.ts.backup +549 -550
  428. package/ccw/src/core/routes/mcp-templates-db.ts +267 -268
  429. package/ccw/src/core/routes/memory-routes.ts +76 -22
  430. package/ccw/src/core/routes/nav-status-routes.ts +231 -0
  431. package/ccw/src/core/routes/rules-routes.ts +600 -81
  432. package/ccw/src/core/routes/session-routes.ts +28 -22
  433. package/ccw/src/core/routes/skills-routes.ts +452 -132
  434. package/ccw/src/core/routes/status-routes.ts +1 -12
  435. package/ccw/src/core/routes/system-routes.ts +15 -22
  436. package/ccw/src/core/routes/types.ts +25 -0
  437. package/ccw/src/core/server.ts +657 -468
  438. package/ccw/src/core/services/api-key-tester.ts +160 -0
  439. package/ccw/src/core/services/health-check-service.ts +366 -0
  440. package/ccw/src/core/websocket.ts +20 -12
  441. package/ccw/src/templates/dashboard-css/01-base.css +109 -0
  442. package/ccw/src/templates/dashboard-css/10-cli-status.css +202 -0
  443. package/ccw/src/templates/dashboard-css/21-cli-toolmgmt.css +308 -0
  444. package/ccw/src/templates/dashboard-css/30-core-memory.css +20 -0
  445. package/ccw/src/templates/dashboard-css/31-api-settings.css +751 -14
  446. package/ccw/src/templates/dashboard-css/33-cli-stream-viewer.css +230 -2
  447. package/ccw/src/templates/dashboard-js/api.js +5 -0
  448. package/ccw/src/templates/dashboard-js/components/cli-status.js +279 -107
  449. package/ccw/src/templates/dashboard-js/components/cli-stream-viewer.js +262 -20
  450. package/ccw/src/templates/dashboard-js/components/hook-manager.js +105 -5
  451. package/ccw/src/templates/dashboard-js/components/mcp-manager.js +317 -0
  452. package/ccw/src/templates/dashboard-js/components/navigation.js +45 -0
  453. package/ccw/src/templates/dashboard-js/components/notifications.js +128 -0
  454. package/ccw/src/templates/dashboard-js/i18n.js +4448 -3983
  455. package/ccw/src/templates/dashboard-js/main.js +71 -0
  456. package/ccw/src/templates/dashboard-js/services.js +289 -0
  457. package/ccw/src/templates/dashboard-js/views/api-settings.js +5613 -3361
  458. package/ccw/src/templates/dashboard-js/views/claude-manager.js +1 -7
  459. package/ccw/src/templates/dashboard-js/views/cli-manager.js +581 -87
  460. package/ccw/src/templates/dashboard-js/views/codexlens-manager.js +6101 -1965
  461. package/ccw/src/templates/dashboard-js/views/core-memory.js +129 -20
  462. package/ccw/src/templates/dashboard-js/views/hook-manager.js +17 -3
  463. package/ccw/src/templates/dashboard-js/views/mcp-manager.js +63 -0
  464. package/ccw/src/templates/dashboard-js/views/project-overview.js +182 -37
  465. package/ccw/src/templates/dashboard-js/views/rules-manager.js +26 -3
  466. package/ccw/src/templates/dashboard-js/views/skills-manager.js +2 -42
  467. package/ccw/src/templates/dashboard.html +6 -0
  468. package/ccw/src/tools/README.md +29 -0
  469. package/ccw/src/tools/claude-cli-tools.ts +640 -125
  470. package/ccw/src/tools/cli-config-manager.ts +102 -172
  471. package/ccw/src/tools/cli-executor-core.ts +1533 -0
  472. package/ccw/src/tools/cli-executor-state.ts +560 -0
  473. package/ccw/src/tools/cli-executor-utils.ts +349 -0
  474. package/ccw/src/tools/cli-executor.ts +3 -2309
  475. package/ccw/src/tools/cli-history-store.ts +2 -0
  476. package/ccw/src/tools/cli-output-converter.ts +1237 -0
  477. package/ccw/src/tools/cli-prompt-builder.ts +487 -0
  478. package/ccw/src/tools/codex-lens.ts +324 -59
  479. package/ccw/src/tools/detect-changed-modules.ts +24 -6
  480. package/ccw/src/tools/index.ts +2 -0
  481. package/ccw/src/tools/litellm-client.ts +10 -4
  482. package/ccw/src/tools/litellm-executor.ts +146 -114
  483. package/ccw/src/tools/native-session-discovery.ts +209 -1
  484. package/ccw/src/tools/session-manager.ts +88 -0
  485. package/ccw/src/tools/skill-context-loader.ts +213 -0
  486. package/ccw/src/tools/smart-search.ts +427 -76
  487. package/ccw/src/types/cli-settings.ts +137 -0
  488. package/ccw/src/types/litellm-api-config.ts +55 -1
  489. package/ccw/src/utils/exec-constants.ts +24 -0
  490. package/ccw/src/utils/path-resolver.ts +49 -3
  491. package/ccw/src/utils/path-validator.ts +28 -6
  492. package/ccw/src/utils/python-utils.ts +140 -121
  493. package/ccw/src/utils/shell-escape.ts +30 -0
  494. package/ccw/src/utils/uv-manager.ts +796 -0
  495. package/ccw-litellm/src/ccw_litellm/__pycache__/__init__.cpython-310.pyc +0 -0
  496. package/ccw-litellm/src/ccw_litellm/__pycache__/__init__.cpython-312.pyc +0 -0
  497. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/__init__.cpython-310.pyc +0 -0
  498. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/__init__.cpython-312.pyc +0 -0
  499. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_embedder.cpython-310.pyc +0 -0
  500. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_embedder.cpython-312.pyc +0 -0
  501. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_embedder.cpython-313.pyc +0 -0
  502. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_llm.cpython-310.pyc +0 -0
  503. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_llm.cpython-312.pyc +0 -0
  504. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_llm.cpython-313.pyc +0 -0
  505. package/ccw-litellm/src/ccw_litellm/clients/litellm_embedder.py +270 -251
  506. package/ccw-litellm/src/ccw_litellm/clients/litellm_llm.py +33 -0
  507. package/ccw-litellm/src/ccw_litellm/config/__pycache__/__init__.cpython-310.pyc +0 -0
  508. package/ccw-litellm/src/ccw_litellm/config/__pycache__/__init__.cpython-312.pyc +0 -0
  509. package/ccw-litellm/src/ccw_litellm/config/__pycache__/loader.cpython-310.pyc +0 -0
  510. package/ccw-litellm/src/ccw_litellm/config/__pycache__/loader.cpython-312.pyc +0 -0
  511. package/ccw-litellm/src/ccw_litellm/config/__pycache__/loader.cpython-313.pyc +0 -0
  512. package/ccw-litellm/src/ccw_litellm/config/__pycache__/models.cpython-310.pyc +0 -0
  513. package/ccw-litellm/src/ccw_litellm/config/__pycache__/models.cpython-312.pyc +0 -0
  514. package/ccw-litellm/src/ccw_litellm/config/__pycache__/models.cpython-313.pyc +0 -0
  515. package/ccw-litellm/src/ccw_litellm/config/loader.py +343 -316
  516. package/ccw-litellm/src/ccw_litellm/config/models.py +162 -130
  517. package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/__init__.cpython-310.pyc +0 -0
  518. package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/__init__.cpython-312.pyc +0 -0
  519. package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/embedder.cpython-310.pyc +0 -0
  520. package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/embedder.cpython-312.pyc +0 -0
  521. package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/llm.cpython-310.pyc +0 -0
  522. package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/llm.cpython-312.pyc +0 -0
  523. package/codex-lens/pyproject.toml +43 -0
  524. package/codex-lens/src/codexlens/__pycache__/__init__.cpython-310.pyc +0 -0
  525. package/codex-lens/src/codexlens/__pycache__/__init__.cpython-312.pyc +0 -0
  526. package/codex-lens/src/codexlens/__pycache__/__main__.cpython-310.pyc +0 -0
  527. package/codex-lens/src/codexlens/__pycache__/__main__.cpython-312.pyc +0 -0
  528. package/codex-lens/src/codexlens/__pycache__/config.cpython-310.pyc +0 -0
  529. package/codex-lens/src/codexlens/__pycache__/config.cpython-312.pyc +0 -0
  530. package/codex-lens/src/codexlens/__pycache__/config.cpython-313.pyc +0 -0
  531. package/codex-lens/src/codexlens/__pycache__/entities.cpython-310.pyc +0 -0
  532. package/codex-lens/src/codexlens/__pycache__/entities.cpython-312.pyc +0 -0
  533. package/codex-lens/src/codexlens/__pycache__/entities.cpython-313.pyc +0 -0
  534. package/codex-lens/src/codexlens/__pycache__/env_config.cpython-310.pyc +0 -0
  535. package/codex-lens/src/codexlens/__pycache__/env_config.cpython-312.pyc +0 -0
  536. package/codex-lens/src/codexlens/__pycache__/env_config.cpython-313.pyc +0 -0
  537. package/codex-lens/src/codexlens/__pycache__/errors.cpython-310.pyc +0 -0
  538. package/codex-lens/src/codexlens/__pycache__/errors.cpython-312.pyc +0 -0
  539. package/codex-lens/src/codexlens/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  540. package/codex-lens/src/codexlens/cli/__pycache__/__init__.cpython-312.pyc +0 -0
  541. package/codex-lens/src/codexlens/cli/__pycache__/commands.cpython-310.pyc +0 -0
  542. package/codex-lens/src/codexlens/cli/__pycache__/commands.cpython-312.pyc +0 -0
  543. package/codex-lens/src/codexlens/cli/__pycache__/commands.cpython-313.pyc +0 -0
  544. package/codex-lens/src/codexlens/cli/__pycache__/embedding_manager.cpython-310.pyc +0 -0
  545. package/codex-lens/src/codexlens/cli/__pycache__/embedding_manager.cpython-312.pyc +0 -0
  546. package/codex-lens/src/codexlens/cli/__pycache__/embedding_manager.cpython-313.pyc +0 -0
  547. package/codex-lens/src/codexlens/cli/__pycache__/model_manager.cpython-310.pyc +0 -0
  548. package/codex-lens/src/codexlens/cli/__pycache__/model_manager.cpython-312.pyc +0 -0
  549. package/codex-lens/src/codexlens/cli/__pycache__/model_manager.cpython-313.pyc +0 -0
  550. package/codex-lens/src/codexlens/cli/__pycache__/output.cpython-310.pyc +0 -0
  551. package/codex-lens/src/codexlens/cli/__pycache__/output.cpython-312.pyc +0 -0
  552. package/codex-lens/src/codexlens/cli/commands.py +4416 -2295
  553. package/codex-lens/src/codexlens/cli/embedding_manager.py +777 -15
  554. package/codex-lens/src/codexlens/cli/model_manager.py +676 -0
  555. package/codex-lens/src/codexlens/config.py +356 -12
  556. package/codex-lens/src/codexlens/entities.py +4 -1
  557. package/codex-lens/src/codexlens/env_config.py +304 -0
  558. package/codex-lens/src/codexlens/indexing/__init__.py +23 -1
  559. package/codex-lens/src/codexlens/indexing/__pycache__/__init__.cpython-313.pyc +0 -0
  560. package/codex-lens/src/codexlens/indexing/__pycache__/embedding.cpython-313.pyc +0 -0
  561. package/codex-lens/src/codexlens/indexing/__pycache__/symbol_extractor.cpython-313.pyc +0 -0
  562. package/codex-lens/src/codexlens/indexing/embedding.py +582 -0
  563. package/codex-lens/src/codexlens/indexing/symbol_extractor.py +62 -28
  564. package/codex-lens/src/codexlens/parsers/__pycache__/__init__.cpython-310.pyc +0 -0
  565. package/codex-lens/src/codexlens/parsers/__pycache__/__init__.cpython-312.pyc +0 -0
  566. package/codex-lens/src/codexlens/parsers/__pycache__/factory.cpython-310.pyc +0 -0
  567. package/codex-lens/src/codexlens/parsers/__pycache__/factory.cpython-312.pyc +0 -0
  568. package/codex-lens/src/codexlens/parsers/__pycache__/factory.cpython-313.pyc +0 -0
  569. package/codex-lens/src/codexlens/parsers/__pycache__/tokenizer.cpython-310.pyc +0 -0
  570. package/codex-lens/src/codexlens/parsers/__pycache__/tokenizer.cpython-312.pyc +0 -0
  571. package/codex-lens/src/codexlens/parsers/__pycache__/treesitter_parser.cpython-310.pyc +0 -0
  572. package/codex-lens/src/codexlens/parsers/__pycache__/treesitter_parser.cpython-312.pyc +0 -0
  573. package/codex-lens/src/codexlens/parsers/__pycache__/treesitter_parser.cpython-313.pyc +0 -0
  574. package/codex-lens/src/codexlens/parsers/factory.py +139 -10
  575. package/codex-lens/src/codexlens/parsers/treesitter_parser.py +487 -13
  576. package/codex-lens/src/codexlens/search/__pycache__/__init__.cpython-310.pyc +0 -0
  577. package/codex-lens/src/codexlens/search/__pycache__/__init__.cpython-312.pyc +0 -0
  578. package/codex-lens/src/codexlens/search/__pycache__/binary_searcher.cpython-313.pyc +0 -0
  579. package/codex-lens/src/codexlens/search/__pycache__/chain_search.cpython-310.pyc +0 -0
  580. package/codex-lens/src/codexlens/search/__pycache__/chain_search.cpython-312.pyc +0 -0
  581. package/codex-lens/src/codexlens/search/__pycache__/chain_search.cpython-313.pyc +0 -0
  582. package/codex-lens/src/codexlens/search/__pycache__/enrichment.cpython-313.pyc +0 -0
  583. package/codex-lens/src/codexlens/search/__pycache__/graph_expander.cpython-313.pyc +0 -0
  584. package/codex-lens/src/codexlens/search/__pycache__/hybrid_search.cpython-310.pyc +0 -0
  585. package/codex-lens/src/codexlens/search/__pycache__/hybrid_search.cpython-312.pyc +0 -0
  586. package/codex-lens/src/codexlens/search/__pycache__/hybrid_search.cpython-313.pyc +0 -0
  587. package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-310.pyc +0 -0
  588. package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-312.pyc +0 -0
  589. package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-313.pyc +0 -0
  590. package/codex-lens/src/codexlens/search/binary_searcher.py +277 -0
  591. package/codex-lens/src/codexlens/search/chain_search.py +1652 -8
  592. package/codex-lens/src/codexlens/search/enrichment.py +21 -0
  593. package/codex-lens/src/codexlens/search/graph_expander.py +264 -0
  594. package/codex-lens/src/codexlens/search/hybrid_search.py +772 -37
  595. package/codex-lens/src/codexlens/search/ranking.py +397 -8
  596. package/codex-lens/src/codexlens/semantic/SPLADE_IMPLEMENTATION.md +225 -0
  597. package/codex-lens/src/codexlens/semantic/__pycache__/__init__.cpython-310.pyc +0 -0
  598. package/codex-lens/src/codexlens/semantic/__pycache__/__init__.cpython-312.pyc +0 -0
  599. package/codex-lens/src/codexlens/semantic/__pycache__/ann_index.cpython-310.pyc +0 -0
  600. package/codex-lens/src/codexlens/semantic/__pycache__/ann_index.cpython-312.pyc +0 -0
  601. package/codex-lens/src/codexlens/semantic/__pycache__/ann_index.cpython-313.pyc +0 -0
  602. package/codex-lens/src/codexlens/semantic/__pycache__/base.cpython-310.pyc +0 -0
  603. package/codex-lens/src/codexlens/semantic/__pycache__/base.cpython-312.pyc +0 -0
  604. package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-310.pyc +0 -0
  605. package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-312.pyc +0 -0
  606. package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-313.pyc +0 -0
  607. package/codex-lens/src/codexlens/semantic/__pycache__/embedder.cpython-310.pyc +0 -0
  608. package/codex-lens/src/codexlens/semantic/__pycache__/embedder.cpython-312.pyc +0 -0
  609. package/codex-lens/src/codexlens/semantic/__pycache__/factory.cpython-310.pyc +0 -0
  610. package/codex-lens/src/codexlens/semantic/__pycache__/factory.cpython-312.pyc +0 -0
  611. package/codex-lens/src/codexlens/semantic/__pycache__/factory.cpython-313.pyc +0 -0
  612. package/codex-lens/src/codexlens/semantic/__pycache__/gpu_support.cpython-310.pyc +0 -0
  613. package/codex-lens/src/codexlens/semantic/__pycache__/gpu_support.cpython-312.pyc +0 -0
  614. package/codex-lens/src/codexlens/semantic/__pycache__/gpu_support.cpython-313.pyc +0 -0
  615. package/codex-lens/src/codexlens/semantic/__pycache__/litellm_embedder.cpython-310.pyc +0 -0
  616. package/codex-lens/src/codexlens/semantic/__pycache__/litellm_embedder.cpython-312.pyc +0 -0
  617. package/codex-lens/src/codexlens/semantic/__pycache__/litellm_embedder.cpython-313.pyc +0 -0
  618. package/codex-lens/src/codexlens/semantic/__pycache__/reranker.cpython-313.pyc +0 -0
  619. package/codex-lens/src/codexlens/semantic/__pycache__/splade_encoder.cpython-310.pyc +0 -0
  620. package/codex-lens/src/codexlens/semantic/__pycache__/splade_encoder.cpython-312.pyc +0 -0
  621. package/codex-lens/src/codexlens/semantic/__pycache__/splade_encoder.cpython-313.pyc +0 -0
  622. package/codex-lens/src/codexlens/semantic/__pycache__/vector_store.cpython-310.pyc +0 -0
  623. package/codex-lens/src/codexlens/semantic/__pycache__/vector_store.cpython-312.pyc +0 -0
  624. package/codex-lens/src/codexlens/semantic/__pycache__/vector_store.cpython-313.pyc +0 -0
  625. package/codex-lens/src/codexlens/semantic/ann_index.py +654 -0
  626. package/codex-lens/src/codexlens/semantic/chunker.py +328 -23
  627. package/codex-lens/src/codexlens/semantic/factory.py +63 -3
  628. package/codex-lens/src/codexlens/semantic/gpu_support.py +19 -2
  629. package/codex-lens/src/codexlens/semantic/litellm_embedder.py +144 -144
  630. package/codex-lens/src/codexlens/semantic/reranker/__init__.py +25 -0
  631. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/__init__.cpython-310.pyc +0 -0
  632. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/__init__.cpython-312.pyc +0 -0
  633. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/__init__.cpython-313.pyc +0 -0
  634. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/api_reranker.cpython-310.pyc +0 -0
  635. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/api_reranker.cpython-312.pyc +0 -0
  636. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/api_reranker.cpython-313.pyc +0 -0
  637. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/base.cpython-310.pyc +0 -0
  638. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/base.cpython-312.pyc +0 -0
  639. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/base.cpython-313.pyc +0 -0
  640. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/factory.cpython-310.pyc +0 -0
  641. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/factory.cpython-312.pyc +0 -0
  642. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/factory.cpython-313.pyc +0 -0
  643. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/fastembed_reranker.cpython-310.pyc +0 -0
  644. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/fastembed_reranker.cpython-312.pyc +0 -0
  645. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/fastembed_reranker.cpython-313.pyc +0 -0
  646. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/legacy.cpython-310.pyc +0 -0
  647. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/legacy.cpython-312.pyc +0 -0
  648. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/legacy.cpython-313.pyc +0 -0
  649. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/litellm_reranker.cpython-313.pyc +0 -0
  650. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/onnx_reranker.cpython-310.pyc +0 -0
  651. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/onnx_reranker.cpython-312.pyc +0 -0
  652. package/codex-lens/src/codexlens/semantic/reranker/__pycache__/onnx_reranker.cpython-313.pyc +0 -0
  653. package/codex-lens/src/codexlens/semantic/reranker/api_reranker.py +403 -0
  654. package/codex-lens/src/codexlens/semantic/reranker/base.py +46 -0
  655. package/codex-lens/src/codexlens/semantic/reranker/factory.py +159 -0
  656. package/codex-lens/src/codexlens/semantic/reranker/fastembed_reranker.py +257 -0
  657. package/codex-lens/src/codexlens/semantic/reranker/legacy.py +91 -0
  658. package/codex-lens/src/codexlens/semantic/reranker/litellm_reranker.py +214 -0
  659. package/codex-lens/src/codexlens/semantic/reranker/onnx_reranker.py +268 -0
  660. package/codex-lens/src/codexlens/semantic/splade_encoder.py +567 -0
  661. package/codex-lens/src/codexlens/semantic/vector_store.py +472 -352
  662. package/codex-lens/src/codexlens/storage/__init__.py +3 -0
  663. package/codex-lens/src/codexlens/storage/__pycache__/__init__.cpython-310.pyc +0 -0
  664. package/codex-lens/src/codexlens/storage/__pycache__/__init__.cpython-312.pyc +0 -0
  665. package/codex-lens/src/codexlens/storage/__pycache__/__init__.cpython-313.pyc +0 -0
  666. package/codex-lens/src/codexlens/storage/__pycache__/dir_index.cpython-310.pyc +0 -0
  667. package/codex-lens/src/codexlens/storage/__pycache__/dir_index.cpython-312.pyc +0 -0
  668. package/codex-lens/src/codexlens/storage/__pycache__/dir_index.cpython-313.pyc +0 -0
  669. package/codex-lens/src/codexlens/storage/__pycache__/global_index.cpython-310.pyc +0 -0
  670. package/codex-lens/src/codexlens/storage/__pycache__/global_index.cpython-312.pyc +0 -0
  671. package/codex-lens/src/codexlens/storage/__pycache__/index_tree.cpython-310.pyc +0 -0
  672. package/codex-lens/src/codexlens/storage/__pycache__/index_tree.cpython-312.pyc +0 -0
  673. package/codex-lens/src/codexlens/storage/__pycache__/index_tree.cpython-313.pyc +0 -0
  674. package/codex-lens/src/codexlens/storage/__pycache__/merkle_tree.cpython-313.pyc +0 -0
  675. package/codex-lens/src/codexlens/storage/__pycache__/path_mapper.cpython-310.pyc +0 -0
  676. package/codex-lens/src/codexlens/storage/__pycache__/path_mapper.cpython-312.pyc +0 -0
  677. package/codex-lens/src/codexlens/storage/__pycache__/registry.cpython-310.pyc +0 -0
  678. package/codex-lens/src/codexlens/storage/__pycache__/registry.cpython-312.pyc +0 -0
  679. package/codex-lens/src/codexlens/storage/__pycache__/splade_index.cpython-310.pyc +0 -0
  680. package/codex-lens/src/codexlens/storage/__pycache__/splade_index.cpython-312.pyc +0 -0
  681. package/codex-lens/src/codexlens/storage/__pycache__/splade_index.cpython-313.pyc +0 -0
  682. package/codex-lens/src/codexlens/storage/__pycache__/sqlite_store.cpython-310.pyc +0 -0
  683. package/codex-lens/src/codexlens/storage/__pycache__/sqlite_store.cpython-312.pyc +0 -0
  684. package/codex-lens/src/codexlens/storage/__pycache__/sqlite_store.cpython-313.pyc +0 -0
  685. package/codex-lens/src/codexlens/storage/__pycache__/sqlite_utils.cpython-310.pyc +0 -0
  686. package/codex-lens/src/codexlens/storage/__pycache__/sqlite_utils.cpython-312.pyc +0 -0
  687. package/codex-lens/src/codexlens/storage/__pycache__/vector_meta_store.cpython-310.pyc +0 -0
  688. package/codex-lens/src/codexlens/storage/__pycache__/vector_meta_store.cpython-312.pyc +0 -0
  689. package/codex-lens/src/codexlens/storage/__pycache__/vector_meta_store.cpython-313.pyc +0 -0
  690. package/codex-lens/src/codexlens/storage/dir_index.py +310 -12
  691. package/codex-lens/src/codexlens/storage/index_tree.py +240 -25
  692. package/codex-lens/src/codexlens/storage/merkle_tree.py +136 -0
  693. package/codex-lens/src/codexlens/storage/migrations/__pycache__/__init__.cpython-310.pyc +0 -0
  694. package/codex-lens/src/codexlens/storage/migrations/__pycache__/__init__.cpython-312.pyc +0 -0
  695. package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_006_enhance_relationships.cpython-313.pyc +0 -0
  696. package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_007_add_graph_neighbors.cpython-310.pyc +0 -0
  697. package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_007_add_graph_neighbors.cpython-312.pyc +0 -0
  698. package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_007_add_graph_neighbors.cpython-313.pyc +0 -0
  699. package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_008_add_merkle_hashes.cpython-313.pyc +0 -0
  700. package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_009_add_splade.cpython-313.pyc +0 -0
  701. package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_010_add_multi_vector_chunks.cpython-313.pyc +0 -0
  702. package/codex-lens/src/codexlens/storage/migrations/migration_006_enhance_relationships.py +37 -0
  703. package/codex-lens/src/codexlens/storage/migrations/migration_007_add_graph_neighbors.py +47 -0
  704. package/codex-lens/src/codexlens/storage/migrations/migration_008_add_merkle_hashes.py +81 -0
  705. package/codex-lens/src/codexlens/storage/migrations/migration_009_add_splade.py +103 -0
  706. package/codex-lens/src/codexlens/storage/migrations/migration_010_add_multi_vector_chunks.py +162 -0
  707. package/codex-lens/src/codexlens/storage/splade_index.py +578 -0
  708. package/codex-lens/src/codexlens/storage/sqlite_store.py +508 -184
  709. package/codex-lens/src/codexlens/storage/vector_meta_store.py +415 -0
  710. package/codex-lens/src/codexlens/watcher/__init__.py +17 -0
  711. package/codex-lens/src/codexlens/watcher/__pycache__/__init__.cpython-310.pyc +0 -0
  712. package/codex-lens/src/codexlens/watcher/__pycache__/__init__.cpython-312.pyc +0 -0
  713. package/codex-lens/src/codexlens/watcher/__pycache__/__init__.cpython-313.pyc +0 -0
  714. package/codex-lens/src/codexlens/watcher/__pycache__/events.cpython-310.pyc +0 -0
  715. package/codex-lens/src/codexlens/watcher/__pycache__/events.cpython-312.pyc +0 -0
  716. package/codex-lens/src/codexlens/watcher/__pycache__/events.cpython-313.pyc +0 -0
  717. package/codex-lens/src/codexlens/watcher/__pycache__/file_watcher.cpython-310.pyc +0 -0
  718. package/codex-lens/src/codexlens/watcher/__pycache__/file_watcher.cpython-312.pyc +0 -0
  719. package/codex-lens/src/codexlens/watcher/__pycache__/file_watcher.cpython-313.pyc +0 -0
  720. package/codex-lens/src/codexlens/watcher/__pycache__/incremental_indexer.cpython-310.pyc +0 -0
  721. package/codex-lens/src/codexlens/watcher/__pycache__/incremental_indexer.cpython-312.pyc +0 -0
  722. package/codex-lens/src/codexlens/watcher/__pycache__/incremental_indexer.cpython-313.pyc +0 -0
  723. package/codex-lens/src/codexlens/watcher/__pycache__/manager.cpython-310.pyc +0 -0
  724. package/codex-lens/src/codexlens/watcher/__pycache__/manager.cpython-312.pyc +0 -0
  725. package/codex-lens/src/codexlens/watcher/__pycache__/manager.cpython-313.pyc +0 -0
  726. package/codex-lens/src/codexlens/watcher/events.py +82 -0
  727. package/codex-lens/src/codexlens/watcher/file_watcher.py +347 -0
  728. package/codex-lens/src/codexlens/watcher/incremental_indexer.py +369 -0
  729. package/codex-lens/src/codexlens/watcher/manager.py +255 -0
  730. package/package.json +4 -1
  731. package/.claude/commands/workflow/docs/analyze.md +0 -1467
  732. package/.claude/commands/workflow/docs/copyright.md +0 -1265
  733. package/.claude/skills/command-guide/SKILL.md +0 -388
  734. package/.claude/skills/command-guide/UPDATE-GUIDELINE.md +0 -592
  735. package/.claude/skills/command-guide/guides/cli-tools-guide.md +0 -410
  736. package/.claude/skills/command-guide/guides/examples.md +0 -537
  737. package/.claude/skills/command-guide/guides/getting-started.md +0 -242
  738. package/.claude/skills/command-guide/guides/implementation-details.md +0 -1010
  739. package/.claude/skills/command-guide/guides/index-structure.md +0 -326
  740. package/.claude/skills/command-guide/guides/troubleshooting.md +0 -92
  741. package/.claude/skills/command-guide/guides/ui-design-workflow-guide.md +0 -316
  742. package/.claude/skills/command-guide/guides/workflow-patterns.md +0 -662
  743. package/.claude/skills/command-guide/reference/agents/action-planning-agent.md +0 -855
  744. package/.claude/skills/command-guide/reference/agents/cli-execution-agent.md +0 -267
  745. package/.claude/skills/command-guide/reference/agents/cli-explore-agent.md +0 -182
  746. package/.claude/skills/command-guide/reference/agents/cli-lite-planning-agent.md +0 -446
  747. package/.claude/skills/command-guide/reference/agents/cli-planning-agent.md +0 -558
  748. package/.claude/skills/command-guide/reference/agents/code-developer.md +0 -311
  749. package/.claude/skills/command-guide/reference/agents/conceptual-planning-agent.md +0 -308
  750. package/.claude/skills/command-guide/reference/agents/context-search-agent.md +0 -581
  751. package/.claude/skills/command-guide/reference/agents/doc-generator.md +0 -330
  752. package/.claude/skills/command-guide/reference/agents/memory-bridge.md +0 -94
  753. package/.claude/skills/command-guide/reference/agents/test-context-search-agent.md +0 -400
  754. package/.claude/skills/command-guide/reference/agents/test-fix-agent.md +0 -344
  755. package/.claude/skills/command-guide/reference/agents/ui-design-agent.md +0 -593
  756. package/.claude/skills/command-guide/reference/agents/universal-executor.md +0 -131
  757. package/.claude/skills/command-guide/reference/commands/cli/cli-init.md +0 -440
  758. package/.claude/skills/command-guide/reference/commands/enhance-prompt.md +0 -93
  759. package/.claude/skills/command-guide/reference/commands/memory/code-map-memory.md +0 -687
  760. package/.claude/skills/command-guide/reference/commands/memory/docs-full-cli.md +0 -471
  761. package/.claude/skills/command-guide/reference/commands/memory/docs-related-cli.md +0 -386
  762. package/.claude/skills/command-guide/reference/commands/memory/docs.md +0 -616
  763. package/.claude/skills/command-guide/reference/commands/memory/load-skill-memory.md +0 -182
  764. package/.claude/skills/command-guide/reference/commands/memory/load.md +0 -240
  765. package/.claude/skills/command-guide/reference/commands/memory/skill-memory.md +0 -525
  766. package/.claude/skills/command-guide/reference/commands/memory/style-skill-memory.md +0 -396
  767. package/.claude/skills/command-guide/reference/commands/memory/tech-research.md +0 -314
  768. package/.claude/skills/command-guide/reference/commands/memory/update-full.md +0 -332
  769. package/.claude/skills/command-guide/reference/commands/memory/update-related.md +0 -332
  770. package/.claude/skills/command-guide/reference/commands/memory/workflow-skill-memory.md +0 -517
  771. package/.claude/skills/command-guide/reference/commands/task/breakdown.md +0 -204
  772. package/.claude/skills/command-guide/reference/commands/task/create.md +0 -152
  773. package/.claude/skills/command-guide/reference/commands/task/execute.md +0 -270
  774. package/.claude/skills/command-guide/reference/commands/task/replan.md +0 -437
  775. package/.claude/skills/command-guide/reference/commands/version.md +0 -254
  776. package/.claude/skills/command-guide/reference/commands/workflow/action-plan-verify.md +0 -447
  777. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/api-designer.md +0 -585
  778. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/artifacts.md +0 -452
  779. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/auto-parallel.md +0 -443
  780. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/data-architect.md +0 -220
  781. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/product-manager.md +0 -200
  782. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/product-owner.md +0 -200
  783. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/scrum-master.md +0 -200
  784. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/subject-matter-expert.md +0 -200
  785. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/synthesis.md +0 -398
  786. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/system-architect.md +0 -387
  787. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/ui-designer.md +0 -221
  788. package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/ux-expert.md +0 -221
  789. package/.claude/skills/command-guide/reference/commands/workflow/execute.md +0 -465
  790. package/.claude/skills/command-guide/reference/commands/workflow/init.md +0 -164
  791. package/.claude/skills/command-guide/reference/commands/workflow/lite-execute.md +0 -748
  792. package/.claude/skills/command-guide/reference/commands/workflow/lite-fix.md +0 -664
  793. package/.claude/skills/command-guide/reference/commands/workflow/lite-plan.md +0 -645
  794. package/.claude/skills/command-guide/reference/commands/workflow/plan.md +0 -551
  795. package/.claude/skills/command-guide/reference/commands/workflow/replan.md +0 -515
  796. package/.claude/skills/command-guide/reference/commands/workflow/review-fix.md +0 -606
  797. package/.claude/skills/command-guide/reference/commands/workflow/review-module-cycle.md +0 -765
  798. package/.claude/skills/command-guide/reference/commands/workflow/review-session-cycle.md +0 -776
  799. package/.claude/skills/command-guide/reference/commands/workflow/review.md +0 -298
  800. package/.claude/skills/command-guide/reference/commands/workflow/session/complete.md +0 -547
  801. package/.claude/skills/command-guide/reference/commands/workflow/session/list.md +0 -114
  802. package/.claude/skills/command-guide/reference/commands/workflow/session/resume.md +0 -77
  803. package/.claude/skills/command-guide/reference/commands/workflow/session/start.md +0 -257
  804. package/.claude/skills/command-guide/reference/commands/workflow/tdd-plan.md +0 -460
  805. package/.claude/skills/command-guide/reference/commands/workflow/tdd-verify.md +0 -400
  806. package/.claude/skills/command-guide/reference/commands/workflow/test-cycle-execute.md +0 -498
  807. package/.claude/skills/command-guide/reference/commands/workflow/test-fix-gen.md +0 -699
  808. package/.claude/skills/command-guide/reference/commands/workflow/test-gen.md +0 -529
  809. package/.claude/skills/command-guide/reference/commands/workflow/tools/conflict-resolution.md +0 -766
  810. package/.claude/skills/command-guide/reference/commands/workflow/tools/context-gather.md +0 -433
  811. package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-agent.md +0 -487
  812. package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-tdd.md +0 -518
  813. package/.claude/skills/command-guide/reference/commands/workflow/tools/tdd-coverage-analysis.md +0 -309
  814. package/.claude/skills/command-guide/reference/commands/workflow/tools/test-concept-enhanced.md +0 -163
  815. package/.claude/skills/command-guide/reference/commands/workflow/tools/test-context-gather.md +0 -232
  816. package/.claude/skills/command-guide/reference/commands/workflow/tools/test-task-generate.md +0 -254
  817. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/animation-extract.md +0 -1150
  818. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/codify-style.md +0 -652
  819. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/design-sync.md +0 -454
  820. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/explore-auto.md +0 -678
  821. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/generate.md +0 -504
  822. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/imitate-auto.md +0 -745
  823. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/import-from-code.md +0 -537
  824. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/layout-extract.md +0 -788
  825. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/reference-page-generator.md +0 -356
  826. package/.claude/skills/command-guide/reference/commands/workflow/ui-design/style-extract.md +0 -773
  827. package/.claude/skills/command-guide/scripts/analyze_commands.py +0 -502
  828. package/.claude/skills/command-guide/scripts/update-index.sh +0 -130
  829. package/.claude/skills/command-guide/templates/issue-bug.md +0 -104
  830. package/.claude/skills/command-guide/templates/issue-diagnosis.md +0 -275
  831. package/.claude/skills/command-guide/templates/issue-feature.md +0 -97
  832. package/.claude/skills/command-guide/templates/issue-question.md +0 -141
@@ -0,0 +1,1237 @@
1
+ /**
2
+ * CLI Output Converter
3
+ * Converts raw CLI tool output into structured Intermediate Representation (IR)
4
+ *
5
+ * Purpose: Decouple output parsing from consumption scenarios (View, Storage, Resume)
6
+ * Supports: Plain text, JSON Lines, and other structured formats
7
+ */
8
+
9
+ // ========== Type Definitions ==========
10
+
11
+ /**
12
+ * Unified output unit types for the intermediate representation layer
13
+ */
14
+ export type CliOutputUnitType =
15
+ | 'stdout' // Standard output text
16
+ | 'stderr' // Standard error text
17
+ | 'thought' // AI reasoning/thinking
18
+ | 'code' // Code block content
19
+ | 'file_diff' // File modification diff
20
+ | 'progress' // Progress updates
21
+ | 'metadata' // Session/execution metadata
22
+ | 'system' // System events/messages
23
+ | 'tool_call'; // Tool invocation/result (Gemini tool_use/tool_result)
24
+
25
+ /**
26
+ * Intermediate Representation unit
27
+ * Common structure for all CLI output chunks
28
+ */
29
+ export interface CliOutputUnit<T = any> {
30
+ type: CliOutputUnitType;
31
+ content: T;
32
+ timestamp: string; // ISO 8601 format
33
+ }
34
+
35
+ // ========== Parser Interface ==========
36
+
37
+ /**
38
+ * Parser interface for converting raw output into IR
39
+ */
40
+ export interface IOutputParser {
41
+ /**
42
+ * Parse a chunk of data from stdout/stderr stream
43
+ * @param chunk - Raw buffer from stream
44
+ * @param streamType - Source stream (stdout or stderr)
45
+ * @returns Array of parsed output units
46
+ */
47
+ parse(chunk: Buffer, streamType: 'stdout' | 'stderr'): CliOutputUnit[];
48
+
49
+ /**
50
+ * Flush any remaining buffered data
51
+ * Called when stream ends to ensure no data is lost
52
+ * @returns Array of remaining output units
53
+ */
54
+ flush(): CliOutputUnit[];
55
+ }
56
+
57
+ // ========== Plain Text Parser ==========
58
+
59
+ /**
60
+ * PlainTextParser - Converts plain text output to IR
61
+ * Simply wraps text in appropriate type envelope
62
+ */
63
+ export class PlainTextParser implements IOutputParser {
64
+ parse(chunk: Buffer, streamType: 'stdout' | 'stderr'): CliOutputUnit[] {
65
+ const text = chunk.toString('utf8');
66
+
67
+ if (!text) {
68
+ return [];
69
+ }
70
+
71
+ return [{
72
+ type: streamType,
73
+ content: text,
74
+ timestamp: new Date().toISOString()
75
+ }];
76
+ }
77
+
78
+ /**
79
+ * Flush any remaining buffered data
80
+ * Called when stream ends to ensure no data is lost
81
+ *
82
+ * Note: PlainTextParser does not buffer data internally, so this method
83
+ * always returns an empty array. Other parsers (e.g., JsonLinesParser)
84
+ * may have buffered incomplete lines that need to be flushed.
85
+ *
86
+ * @returns Array of remaining output units (always empty for PlainTextParser)
87
+ */
88
+ flush(): CliOutputUnit[] {
89
+ // Plain text parser has no internal buffer
90
+ return [];
91
+ }
92
+ }
93
+
94
+ // ========== JSON Lines Parser ==========
95
+
96
+ /**
97
+ * JsonLinesParser - Parses newline-delimited JSON output
98
+ *
99
+ * Features:
100
+ * - Handles incomplete lines across chunks
101
+ * - Maps JSON events to appropriate IR types
102
+ * - Falls back to stdout for unparseable lines
103
+ * - Robust error handling for malformed JSON
104
+ */
105
+ export class JsonLinesParser implements IOutputParser {
106
+ private buffer: string = '';
107
+
108
+ /**
109
+ * Classify non-JSON content to determine appropriate output type
110
+ * Helps distinguish real errors from normal progress/output sent to stderr
111
+ * (Some CLI tools like Codex send all progress info to stderr)
112
+ */
113
+ private classifyNonJsonContent(content: string, originalType: 'stdout' | 'stderr'): 'stdout' | 'stderr' {
114
+ // If it came from stdout, keep it as stdout
115
+ if (originalType === 'stdout') {
116
+ return 'stdout';
117
+ }
118
+
119
+ // Check if content looks like an actual error
120
+ const errorPatterns = [
121
+ /^error:/i,
122
+ /^fatal:/i,
123
+ /^failed:/i,
124
+ /^exception:/i,
125
+ /\bERROR\b/,
126
+ /\bFATAL\b/,
127
+ /\bFAILED\b/,
128
+ /\bpanic:/i,
129
+ /traceback \(most recent/i,
130
+ /syntaxerror:/i,
131
+ /typeerror:/i,
132
+ /referenceerror:/i,
133
+ /\bstack trace\b/i,
134
+ /\bat line \d+\b/i,
135
+ /permission denied/i,
136
+ /access denied/i,
137
+ /authentication failed/i,
138
+ /connection refused/i,
139
+ /network error/i,
140
+ /unable to connect/i,
141
+ ];
142
+
143
+ for (const pattern of errorPatterns) {
144
+ if (pattern.test(content)) {
145
+ return 'stderr';
146
+ }
147
+ }
148
+
149
+ // Check for common CLI progress/info patterns that are NOT errors
150
+ const progressPatterns = [
151
+ /^[-=]+$/, // Separators: ----, ====
152
+ /^\s*\d+\s*$/, // Just numbers
153
+ /tokens?\s*(used|count)/i, // Token counts
154
+ /model:/i, // Model info
155
+ /session\s*id:/i, // Session info
156
+ /workdir:/i, // Working directory
157
+ /provider:/i, // Provider info
158
+ /^(user|assistant|codex|claude|gemini)$/i, // Role labels
159
+ /^mcp:/i, // MCP status
160
+ /^[-\s]*$/, // Empty or whitespace/dashes
161
+ ];
162
+
163
+ for (const pattern of progressPatterns) {
164
+ if (pattern.test(content)) {
165
+ return 'stdout'; // Treat as normal output, not error
166
+ }
167
+ }
168
+
169
+ // Default: if stderr but doesn't look like an error, treat as stdout
170
+ // This handles CLI tools that send everything to stderr (like Codex)
171
+ return 'stdout';
172
+ }
173
+
174
+ parse(chunk: Buffer, streamType: 'stdout' | 'stderr'): CliOutputUnit[] {
175
+ const text = chunk.toString('utf8');
176
+ this.buffer += text;
177
+
178
+ const units: CliOutputUnit[] = [];
179
+ const lines = this.buffer.split('\n');
180
+
181
+ // Keep the last incomplete line in buffer
182
+ this.buffer = lines.pop() || '';
183
+
184
+ for (const line of lines) {
185
+ const trimmed = line.trim();
186
+ if (!trimmed) {
187
+ continue;
188
+ }
189
+
190
+ // Try to parse as JSON
191
+ let parsed: any;
192
+ try {
193
+ parsed = JSON.parse(trimmed);
194
+ } catch {
195
+ // Not valid JSON, treat as plain text
196
+ // For stderr content, check if it's actually an error or just normal output
197
+ // (Some CLI tools like Codex send all progress info to stderr)
198
+ const effectiveType = this.classifyNonJsonContent(line, streamType);
199
+ units.push({
200
+ type: effectiveType,
201
+ content: line,
202
+ timestamp: new Date().toISOString()
203
+ });
204
+ continue;
205
+ }
206
+
207
+ // Map JSON structure to IR type
208
+ const unit = this.mapJsonToIR(parsed, streamType);
209
+ if (unit) {
210
+ units.push(unit);
211
+ }
212
+ }
213
+
214
+ return units;
215
+ }
216
+
217
+ flush(): CliOutputUnit[] {
218
+ const units: CliOutputUnit[] = [];
219
+
220
+ if (this.buffer.trim()) {
221
+ // Try to parse remaining buffer
222
+ try {
223
+ const parsed = JSON.parse(this.buffer.trim());
224
+ const unit = this.mapJsonToIR(parsed, 'stdout');
225
+ if (unit) {
226
+ units.push(unit);
227
+ }
228
+ } catch {
229
+ // Not valid JSON, return as plain text
230
+ units.push({
231
+ type: 'stdout',
232
+ content: this.buffer,
233
+ timestamp: new Date().toISOString()
234
+ });
235
+ }
236
+ }
237
+
238
+ this.buffer = '';
239
+ return units;
240
+ }
241
+
242
+ /**
243
+ * Map parsed JSON object to appropriate IR type
244
+ * Handles various JSON event formats from different CLI tools:
245
+ * - Gemini CLI: stream-json format (init, message, result)
246
+ * - Codex CLI: --json format (thread.started, item.completed, turn.completed)
247
+ * - Claude CLI: stream-json format (system, assistant, result)
248
+ * - OpenCode CLI: --format json (step_start, text, step_finish)
249
+ */
250
+ private mapJsonToIR(json: any, fallbackStreamType: 'stdout' | 'stderr'): CliOutputUnit | null {
251
+ // Handle numeric timestamp (milliseconds) from OpenCode
252
+ const timestamp = typeof json.timestamp === 'number'
253
+ ? new Date(json.timestamp).toISOString()
254
+ : (json.timestamp || new Date().toISOString());
255
+
256
+ // ========== Gemini CLI stream-json format ==========
257
+ // {"type":"init","timestamp":"...","session_id":"...","model":"..."}
258
+ // {"type":"message","timestamp":"...","role":"assistant","content":"...","delta":true}
259
+ // {"type":"result","timestamp":"...","status":"success","stats":{...}}
260
+ if (json.type === 'init' && json.session_id) {
261
+ return {
262
+ type: 'metadata',
263
+ content: {
264
+ tool: 'gemini',
265
+ sessionId: json.session_id,
266
+ model: json.model,
267
+ raw: json
268
+ },
269
+ timestamp
270
+ };
271
+ }
272
+
273
+ if (json.type === 'message' && json.role) {
274
+ // Gemini assistant/user message
275
+ if (json.role === 'assistant') {
276
+ return {
277
+ type: 'stdout',
278
+ content: json.content || '',
279
+ timestamp
280
+ };
281
+ }
282
+ // Skip user messages in output (they're echo of input)
283
+ return null;
284
+ }
285
+
286
+ if (json.type === 'result' && json.stats) {
287
+ return {
288
+ type: 'metadata',
289
+ content: {
290
+ tool: 'gemini',
291
+ status: json.status,
292
+ stats: json.stats,
293
+ raw: json
294
+ },
295
+ timestamp
296
+ };
297
+ }
298
+
299
+ // Gemini tool_use: {"type":"tool_use","timestamp":"...","tool_name":"...","tool_id":"...","parameters":{...}}
300
+ if (json.type === 'tool_use' && json.tool_name) {
301
+ return {
302
+ type: 'tool_call',
303
+ content: {
304
+ tool: 'gemini',
305
+ action: 'invoke',
306
+ toolName: json.tool_name,
307
+ toolId: json.tool_id,
308
+ parameters: json.parameters,
309
+ raw: json
310
+ },
311
+ timestamp
312
+ };
313
+ }
314
+
315
+ // Gemini tool_result: {"type":"tool_result","timestamp":"...","tool_id":"...","status":"...","output":"..."}
316
+ if (json.type === 'tool_result' && json.tool_id) {
317
+ return {
318
+ type: 'tool_call',
319
+ content: {
320
+ tool: 'gemini',
321
+ action: 'result',
322
+ toolId: json.tool_id,
323
+ status: json.status,
324
+ output: json.output,
325
+ raw: json
326
+ },
327
+ timestamp
328
+ };
329
+ }
330
+
331
+ // ========== Codex CLI --json format ==========
332
+ // {"type":"thread.started","thread_id":"..."}
333
+ // {"type":"turn.started"}
334
+ // {"type":"item.started","item":{"id":"...","type":"command_execution","status":"in_progress"}}
335
+ // {"type":"item.completed","item":{"id":"...","type":"reasoning","text":"..."}}
336
+ // {"type":"item.completed","item":{"id":"...","type":"agent_message","text":"..."}}
337
+ // {"type":"item.completed","item":{"id":"...","type":"command_execution","aggregated_output":"..."}}
338
+ // {"type":"turn.completed","usage":{"input_tokens":...,"output_tokens":...}}
339
+ if (json.type === 'thread.started' && json.thread_id) {
340
+ return {
341
+ type: 'metadata',
342
+ content: {
343
+ tool: 'codex',
344
+ threadId: json.thread_id,
345
+ raw: json
346
+ },
347
+ timestamp
348
+ };
349
+ }
350
+
351
+ if (json.type === 'turn.started') {
352
+ return {
353
+ type: 'progress',
354
+ content: {
355
+ message: 'Turn started',
356
+ tool: 'codex'
357
+ },
358
+ timestamp
359
+ };
360
+ }
361
+
362
+ // Handle item.started - command execution in progress
363
+ if (json.type === 'item.started' && json.item) {
364
+ const item = json.item;
365
+ if (item.type === 'command_execution') {
366
+ return {
367
+ type: 'progress',
368
+ content: {
369
+ message: `Executing: ${item.command || 'command'}`,
370
+ tool: 'codex',
371
+ status: item.status || 'in_progress'
372
+ },
373
+ timestamp
374
+ };
375
+ }
376
+ // Other item.started types
377
+ return {
378
+ type: 'progress',
379
+ content: {
380
+ message: `Starting: ${item.type}`,
381
+ tool: 'codex'
382
+ },
383
+ timestamp
384
+ };
385
+ }
386
+
387
+ if (json.type === 'item.completed' && json.item) {
388
+ const item = json.item;
389
+
390
+ if (item.type === 'reasoning') {
391
+ return {
392
+ type: 'thought',
393
+ content: item.text || item.summary || '',
394
+ timestamp
395
+ };
396
+ }
397
+
398
+ if (item.type === 'agent_message') {
399
+ return {
400
+ type: 'stdout',
401
+ content: item.text || '',
402
+ timestamp
403
+ };
404
+ }
405
+
406
+ // Handle command_execution output
407
+ if (item.type === 'command_execution') {
408
+ // Show command output as code block
409
+ const output = item.aggregated_output || '';
410
+ return {
411
+ type: 'code',
412
+ content: {
413
+ command: item.command,
414
+ output: output,
415
+ exitCode: item.exit_code,
416
+ status: item.status
417
+ },
418
+ timestamp
419
+ };
420
+ }
421
+
422
+ // Other item types (function_call, etc.)
423
+ return {
424
+ type: 'system',
425
+ content: {
426
+ itemType: item.type,
427
+ itemId: item.id,
428
+ raw: item
429
+ },
430
+ timestamp
431
+ };
432
+ }
433
+
434
+ if (json.type === 'turn.completed' && json.usage) {
435
+ return {
436
+ type: 'metadata',
437
+ content: {
438
+ tool: 'codex',
439
+ usage: json.usage,
440
+ raw: json
441
+ },
442
+ timestamp
443
+ };
444
+ }
445
+
446
+ // ========== Claude CLI stream-json format ==========
447
+ // {"type":"system","subtype":"init","cwd":"...","session_id":"...","tools":[...],"model":"..."}
448
+ // {"type":"assistant","message":{...},"session_id":"..."}
449
+ // {"type":"result","subtype":"success","duration_ms":...,"result":"...","total_cost_usd":...}
450
+ if (json.type === 'system' && json.subtype === 'init') {
451
+ return {
452
+ type: 'metadata',
453
+ content: {
454
+ tool: 'claude',
455
+ sessionId: json.session_id,
456
+ model: json.model,
457
+ cwd: json.cwd,
458
+ tools: json.tools,
459
+ mcpServers: json.mcp_servers,
460
+ raw: json
461
+ },
462
+ timestamp
463
+ };
464
+ }
465
+
466
+ if (json.type === 'assistant' && json.message) {
467
+ // Extract text content from Claude message
468
+ const message = json.message;
469
+ const textContent = message.content
470
+ ?.filter((c: any) => c.type === 'text')
471
+ .map((c: any) => c.text)
472
+ .join('\n') || '';
473
+
474
+ return {
475
+ type: 'stdout',
476
+ content: textContent,
477
+ timestamp
478
+ };
479
+ }
480
+
481
+ if (json.type === 'result' && json.subtype) {
482
+ return {
483
+ type: 'metadata',
484
+ content: {
485
+ tool: 'claude',
486
+ status: json.subtype,
487
+ result: json.result,
488
+ durationMs: json.duration_ms,
489
+ totalCostUsd: json.total_cost_usd,
490
+ usage: json.usage,
491
+ modelUsage: json.modelUsage,
492
+ raw: json
493
+ },
494
+ timestamp
495
+ };
496
+ }
497
+
498
+ // ========== OpenCode CLI --format json ==========
499
+ // {"type":"step_start","timestamp":...,"sessionID":"...","part":{...}}
500
+ // {"type":"text","timestamp":...,"sessionID":"...","part":{"type":"text","text":"..."}}
501
+ // {"type":"tool_use","timestamp":...,"sessionID":"...","part":{"type":"tool","tool":"glob","input":{...},"state":{...}}}
502
+ // {"type":"step_finish","timestamp":...,"part":{"tokens":{...}}}
503
+ if (json.type === 'step_start' && json.sessionID) {
504
+ return {
505
+ type: 'progress',
506
+ content: {
507
+ message: 'Step started',
508
+ tool: 'opencode',
509
+ sessionId: json.sessionID
510
+ },
511
+ timestamp
512
+ };
513
+ }
514
+
515
+ if (json.type === 'text' && json.part) {
516
+ return {
517
+ type: 'stdout',
518
+ content: json.part.text || '',
519
+ timestamp
520
+ };
521
+ }
522
+
523
+ // OpenCode tool_use: {"type":"tool_use","part":{"type":"tool","tool":"glob","input":{...},"state":{"status":"..."}}}
524
+ if (json.type === 'tool_use' && json.part) {
525
+ const part = json.part;
526
+ const toolName = part.tool || 'unknown';
527
+ const status = part.state?.status || 'in_progress';
528
+ const input = part.input || {};
529
+
530
+ return {
531
+ type: 'tool_call',
532
+ content: {
533
+ tool: 'opencode',
534
+ action: status === 'completed' ? 'result' : 'invoke',
535
+ toolName: toolName,
536
+ toolId: part.callID || part.id,
537
+ parameters: input,
538
+ status: status,
539
+ output: part.output
540
+ },
541
+ timestamp
542
+ };
543
+ }
544
+
545
+ if (json.type === 'step_finish' && json.part) {
546
+ const tokens = json.part.tokens || {};
547
+ const inputTokens = tokens.input || 0;
548
+ const outputTokens = tokens.output || 0;
549
+
550
+ return {
551
+ type: 'metadata',
552
+ content: {
553
+ tool: 'opencode',
554
+ reason: json.part.reason,
555
+ tokens: { input: inputTokens, output: outputTokens },
556
+ cost: json.part.cost
557
+ },
558
+ timestamp
559
+ };
560
+ }
561
+
562
+ // ========== Legacy/Generic formats ==========
563
+ // Check for generic type field patterns
564
+ if (json.type) {
565
+ switch (json.type) {
566
+ case 'thought':
567
+ case 'thinking':
568
+ case 'reasoning':
569
+ return {
570
+ type: 'thought',
571
+ content: json.content || json.text || json.message,
572
+ timestamp
573
+ };
574
+
575
+ case 'code':
576
+ case 'code_block':
577
+ return {
578
+ type: 'code',
579
+ content: json.content || json.code,
580
+ timestamp
581
+ };
582
+
583
+ case 'diff':
584
+ case 'file_diff':
585
+ case 'file_change':
586
+ return {
587
+ type: 'file_diff',
588
+ content: {
589
+ path: json.path || json.file,
590
+ diff: json.diff || json.content,
591
+ action: json.action || 'modify'
592
+ },
593
+ timestamp
594
+ };
595
+
596
+ case 'progress':
597
+ case 'status':
598
+ return {
599
+ type: 'progress',
600
+ content: {
601
+ message: json.message || json.content,
602
+ progress: json.progress,
603
+ total: json.total
604
+ },
605
+ timestamp
606
+ };
607
+
608
+ case 'metadata':
609
+ case 'session_meta':
610
+ return {
611
+ type: 'metadata',
612
+ content: json.payload || json.data || json,
613
+ timestamp
614
+ };
615
+
616
+ case 'system':
617
+ case 'event':
618
+ return {
619
+ type: 'system',
620
+ content: json.message || json.content || json,
621
+ timestamp
622
+ };
623
+ }
624
+ }
625
+
626
+ // Check for legacy Codex JSONL format (response_item)
627
+ if (json.type === 'response_item' && json.payload) {
628
+ const payloadType = json.payload.type;
629
+
630
+ if (payloadType === 'message') {
631
+ // User or assistant message
632
+ const content = json.payload.content
633
+ ?.map((c: any) => c.text || '')
634
+ .filter((t: string) => t)
635
+ .join('\n') || '';
636
+
637
+ return {
638
+ type: 'stdout',
639
+ content,
640
+ timestamp
641
+ };
642
+ }
643
+
644
+ if (payloadType === 'reasoning') {
645
+ return {
646
+ type: 'thought',
647
+ content: json.payload.summary || json.payload.content,
648
+ timestamp
649
+ };
650
+ }
651
+
652
+ if (payloadType === 'function_call' || payloadType === 'function_call_output') {
653
+ return {
654
+ type: 'system',
655
+ content: json.payload,
656
+ timestamp
657
+ };
658
+ }
659
+ }
660
+
661
+ // Check for Gemini/Qwen message format (role-based)
662
+ if (json.role === 'user' || json.role === 'assistant') {
663
+ return {
664
+ type: 'stdout',
665
+ content: json.content || json.text || '',
666
+ timestamp
667
+ };
668
+ }
669
+
670
+ // Check for thoughts array
671
+ if (json.thoughts && Array.isArray(json.thoughts)) {
672
+ return {
673
+ type: 'thought',
674
+ content: json.thoughts.map((t: any) =>
675
+ typeof t === 'string' ? t : `${t.subject}: ${t.description}`
676
+ ).join('\n'),
677
+ timestamp
678
+ };
679
+ }
680
+
681
+ // Default: treat as stdout/stderr based on fallback
682
+ if (json.content || json.message || json.text) {
683
+ return {
684
+ type: fallbackStreamType,
685
+ content: json.content || json.message || json.text,
686
+ timestamp
687
+ };
688
+ }
689
+
690
+ // Unrecognized structure, return as metadata
691
+ return {
692
+ type: 'metadata',
693
+ content: json,
694
+ timestamp
695
+ };
696
+ }
697
+ }
698
+
699
+ // ========== Smart Content Formatter ==========
700
+
701
+ /**
702
+ * Intelligent content formatter that detects and formats JSON content
703
+ * based on structural patterns rather than hardcoded tool-specific formats.
704
+ *
705
+ * Key detection patterns:
706
+ * - Session/Metadata: session_id, sessionID, thread_id, model, stats
707
+ * - Tool Calls: tool_name, tool, function_name, parameters
708
+ * - Progress: status, progress, state, reason
709
+ * - Tokens: tokens, usage, input_tokens, output_tokens
710
+ * - Text Content: content, text, message
711
+ */
712
+ export class SmartContentFormatter {
713
+ /**
714
+ * Format structured content into human-readable text
715
+ * NEVER returns null - always returns displayable content to prevent data loss
716
+ */
717
+ static format(content: any, type: CliOutputUnitType): string {
718
+ // Handle null/undefined
719
+ if (content === null || content === undefined) {
720
+ return '';
721
+ }
722
+
723
+ // String content - return as-is
724
+ if (typeof content === 'string') {
725
+ return content;
726
+ }
727
+
728
+ // Primitive types - convert to string
729
+ if (typeof content !== 'object') {
730
+ return String(content);
731
+ }
732
+
733
+ // Type-specific formatting with fallback chain
734
+ let result: string | null = null;
735
+
736
+ switch (type) {
737
+ case 'metadata':
738
+ result = this.formatMetadata(content);
739
+ break;
740
+ case 'progress':
741
+ result = this.formatProgress(content);
742
+ break;
743
+ case 'tool_call':
744
+ result = this.formatToolCall(content);
745
+ break;
746
+ case 'code':
747
+ result = this.formatCode(content);
748
+ break;
749
+ case 'file_diff':
750
+ result = this.formatFileDiff(content);
751
+ break;
752
+ case 'thought':
753
+ result = this.formatThought(content);
754
+ break;
755
+ case 'system':
756
+ result = this.formatSystem(content);
757
+ break;
758
+ default:
759
+ // Try to extract text content from common fields
760
+ result = this.extractTextContent(content);
761
+ }
762
+
763
+ // If type-specific formatting succeeded, return it
764
+ if (result && result.trim()) {
765
+ return result;
766
+ }
767
+
768
+ // Fallback: try to extract any text content regardless of type
769
+ const textContent = this.extractTextContent(content);
770
+ if (textContent && textContent.trim()) {
771
+ return textContent;
772
+ }
773
+
774
+ // Last resort: format as readable JSON with type hint
775
+ return this.formatAsReadableJson(content, type);
776
+ }
777
+
778
+ /**
779
+ * Format object as readable JSON with type hint (fallback for unknown content)
780
+ * Ensures content is never lost
781
+ */
782
+ private static formatAsReadableJson(content: any, type: CliOutputUnitType): string {
783
+ try {
784
+ const jsonStr = JSON.stringify(content, null, 0);
785
+ // For short content, show inline; for long content, indicate it's data
786
+ if (jsonStr.length <= 200) {
787
+ return `[${type}] ${jsonStr}`;
788
+ }
789
+ // For long content, show truncated with type indicator
790
+ return `[${type}] ${jsonStr.substring(0, 200)}...`;
791
+ } catch {
792
+ // If JSON.stringify fails, try to extract keys
793
+ const keys = Object.keys(content).slice(0, 5).join(', ');
794
+ return `[${type}] {${keys}${Object.keys(content).length > 5 ? ', ...' : ''}}`;
795
+ }
796
+ }
797
+
798
+ /**
799
+ * Format metadata (session info, stats, etc.)
800
+ * Returns null if no meaningful metadata could be extracted
801
+ */
802
+ private static formatMetadata(content: any): string | null {
803
+ const parts: string[] = [];
804
+
805
+ // Tool identifier
806
+ if (content.tool) {
807
+ parts.push(`[${content.tool.toUpperCase()}]`);
808
+ }
809
+
810
+ // Session ID
811
+ const sessionId = content.sessionId || content.session_id || content.threadId || content.thread_id;
812
+ if (sessionId) {
813
+ parts.push(`Session: ${this.truncate(sessionId, 20)}`);
814
+ }
815
+
816
+ // Model info
817
+ if (content.model) {
818
+ parts.push(`Model: ${content.model}`);
819
+ }
820
+
821
+ // Status
822
+ if (content.status) {
823
+ parts.push(`Status: ${content.status}`);
824
+ }
825
+
826
+ // Reason (for step_finish events)
827
+ if (content.reason) {
828
+ parts.push(`Reason: ${content.reason}`);
829
+ }
830
+
831
+ // Duration
832
+ if (content.durationMs || content.duration_ms) {
833
+ const ms = content.durationMs || content.duration_ms;
834
+ parts.push(`Duration: ${this.formatDuration(ms)}`);
835
+ }
836
+
837
+ // Token usage
838
+ const tokens = this.extractTokens(content);
839
+ if (tokens) {
840
+ parts.push(`Tokens: ${tokens}`);
841
+ }
842
+
843
+ // Cost
844
+ if (content.totalCostUsd !== undefined || content.total_cost_usd !== undefined || content.cost !== undefined) {
845
+ const cost = content.totalCostUsd ?? content.total_cost_usd ?? content.cost;
846
+ parts.push(`Cost: $${typeof cost === 'number' ? cost.toFixed(6) : cost}`);
847
+ }
848
+
849
+ // Result
850
+ if (content.result && typeof content.result === 'string') {
851
+ parts.push(`Result: ${this.truncate(content.result, 100)}`);
852
+ }
853
+
854
+ // Return null if no meaningful parts extracted (let fallback handle it)
855
+ return parts.length > 0 ? parts.join(' | ') : null;
856
+ }
857
+
858
+ /**
859
+ * Format progress updates
860
+ * Returns null if no meaningful progress info could be extracted
861
+ */
862
+ private static formatProgress(content: any): string | null {
863
+ const parts: string[] = [];
864
+
865
+ // Tool identifier
866
+ if (content.tool) {
867
+ parts.push(`[${content.tool.toUpperCase()}]`);
868
+ }
869
+
870
+ // Message
871
+ if (content.message) {
872
+ parts.push(content.message);
873
+ }
874
+
875
+ // Status
876
+ if (content.status) {
877
+ parts.push(`(${content.status})`);
878
+ }
879
+
880
+ // Progress indicator
881
+ if (content.progress !== undefined && content.total !== undefined) {
882
+ parts.push(`[${content.progress}/${content.total}]`);
883
+ }
884
+
885
+ // Session ID (brief) - only show if no message (avoid duplication)
886
+ const sessionId = content.sessionId || content.session_id;
887
+ if (sessionId && !content.message) {
888
+ parts.push(`Session: ${this.truncate(sessionId, 12)}`);
889
+ }
890
+
891
+ // Return null if no meaningful parts extracted (let fallback handle it)
892
+ return parts.length > 0 ? parts.join(' ') : null;
893
+ }
894
+
895
+ /**
896
+ * Format tool call (invoke/result)
897
+ */
898
+ private static formatToolCall(content: any): string {
899
+ const toolName = content.toolName || content.tool_name || content.name || 'unknown';
900
+ const action = content.action || 'invoke';
901
+ const status = content.status;
902
+
903
+ if (action === 'result') {
904
+ const statusText = status || 'completed';
905
+ let result = `[Tool Result] ${toolName}: ${statusText}`;
906
+ if (content.output) {
907
+ const outputStr = typeof content.output === 'string' ? content.output : JSON.stringify(content.output);
908
+ result += ` → ${this.truncate(outputStr, 150)}`;
909
+ }
910
+ return result;
911
+ } else {
912
+ // invoke
913
+ let params = '';
914
+ if (content.parameters) {
915
+ const paramStr = typeof content.parameters === 'string'
916
+ ? content.parameters
917
+ : JSON.stringify(content.parameters);
918
+ params = this.truncate(paramStr, 100);
919
+ }
920
+ return `[Tool] ${toolName}(${params})`;
921
+ }
922
+ }
923
+
924
+ /**
925
+ * Format code block
926
+ */
927
+ private static formatCode(content: any): string {
928
+ if (typeof content === 'string') {
929
+ return `\`\`\`\n${content}\n\`\`\``;
930
+ }
931
+
932
+ const lang = content.language || '';
933
+ const code = content.code || content.output || content.content || '';
934
+ const command = content.command;
935
+
936
+ let result = '';
937
+ if (command) {
938
+ result += `$ ${command}\n`;
939
+ }
940
+ result += `\`\`\`${lang}\n${code}\n\`\`\``;
941
+
942
+ if (content.exitCode !== undefined) {
943
+ result += `\n(exit: ${content.exitCode})`;
944
+ }
945
+
946
+ return result;
947
+ }
948
+
949
+ /**
950
+ * Format file diff
951
+ */
952
+ private static formatFileDiff(content: any): string {
953
+ const path = content.path || content.file || 'unknown';
954
+ const action = content.action || 'modify';
955
+ const diff = content.diff || content.content || '';
956
+
957
+ return `[${action.toUpperCase()}] ${path}\n\`\`\`diff\n${diff}\n\`\`\``;
958
+ }
959
+
960
+ /**
961
+ * Format thought/reasoning
962
+ * Returns null if no text content could be extracted
963
+ */
964
+ private static formatThought(content: any): string | null {
965
+ if (typeof content === 'string') {
966
+ return `💭 ${content}`;
967
+ }
968
+ const text = content.text || content.summary || content.content || content.thinking;
969
+ return text ? `💭 ${text}` : null;
970
+ }
971
+
972
+ /**
973
+ * Format system message
974
+ * Returns null if no message content could be extracted
975
+ */
976
+ private static formatSystem(content: any): string | null {
977
+ if (typeof content === 'string') {
978
+ return `⚙️ ${content}`;
979
+ }
980
+ const message = content.message || content.content || content.event || content.info;
981
+ return message ? `⚙️ ${message}` : null;
982
+ }
983
+
984
+ /**
985
+ * Extract text content from common fields
986
+ */
987
+ private static extractTextContent(content: any): string | null {
988
+ // Priority order for text extraction
989
+ const textFields = ['text', 'content', 'message', 'output', 'data'];
990
+
991
+ for (const field of textFields) {
992
+ if (content[field] && typeof content[field] === 'string') {
993
+ return content[field];
994
+ }
995
+ }
996
+
997
+ // Check for nested content
998
+ if (content.part && typeof content.part === 'object') {
999
+ const nested = this.extractTextContent(content.part);
1000
+ if (nested) return nested;
1001
+ }
1002
+
1003
+ // Check for item content (Codex format)
1004
+ if (content.item && typeof content.item === 'object') {
1005
+ const nested = this.extractTextContent(content.item);
1006
+ if (nested) return nested;
1007
+ }
1008
+
1009
+ return null;
1010
+ }
1011
+
1012
+ /**
1013
+ * Extract token usage from various formats
1014
+ */
1015
+ private static extractTokens(content: any): string | null {
1016
+ // Direct tokens object
1017
+ if (content.tokens && typeof content.tokens === 'object') {
1018
+ const input = content.tokens.input || content.tokens.input_tokens || 0;
1019
+ const output = content.tokens.output || content.tokens.output_tokens || 0;
1020
+ return `${input}↓ ${output}↑`;
1021
+ }
1022
+
1023
+ // Usage object
1024
+ if (content.usage && typeof content.usage === 'object') {
1025
+ const input = content.usage.input_tokens || content.usage.inputTokens || 0;
1026
+ const output = content.usage.output_tokens || content.usage.outputTokens || 0;
1027
+ return `${input}↓ ${output}↑`;
1028
+ }
1029
+
1030
+ // Stats object
1031
+ if (content.stats && typeof content.stats === 'object') {
1032
+ const input = content.stats.input_tokens || content.stats.inputTokens || 0;
1033
+ const output = content.stats.output_tokens || content.stats.outputTokens || 0;
1034
+ if (input || output) {
1035
+ return `${input}↓ ${output}↑`;
1036
+ }
1037
+ }
1038
+
1039
+ return null;
1040
+ }
1041
+
1042
+ /**
1043
+ * Truncate string to max length
1044
+ */
1045
+ private static truncate(str: string, maxLen: number): string {
1046
+ if (!str || str.length <= maxLen) return str;
1047
+ return str.substring(0, maxLen) + '...';
1048
+ }
1049
+
1050
+ /**
1051
+ * Format duration from milliseconds
1052
+ */
1053
+ private static formatDuration(ms: number): string {
1054
+ if (ms < 1000) return `${ms}ms`;
1055
+ const s = Math.floor(ms / 1000);
1056
+ if (s < 60) return `${s}s`;
1057
+ const m = Math.floor(s / 60);
1058
+ const rs = s % 60;
1059
+ return `${m}m ${rs}s`;
1060
+ }
1061
+ }
1062
+
1063
+ // ========== Factory Function ==========
1064
+
1065
+ /**
1066
+ * Create an output parser instance based on format
1067
+ * @param format - Output format type
1068
+ * @returns Parser instance
1069
+ */
1070
+ export function createOutputParser(format: 'text' | 'json-lines'): IOutputParser {
1071
+ switch (format) {
1072
+ case 'json-lines':
1073
+ return new JsonLinesParser();
1074
+ case 'text':
1075
+ default:
1076
+ return new PlainTextParser();
1077
+ }
1078
+ }
1079
+
1080
+ // ========== Utility Functions ==========
1081
+
1082
+ /**
1083
+ * Flatten output units into plain text string
1084
+ * Useful for Resume scenario where we need concatenated context
1085
+ *
1086
+ * @param units - Array of output units to flatten
1087
+ * @param options - Filtering and formatting options
1088
+ * @returns Concatenated text content
1089
+ */
1090
+ export function flattenOutputUnits(
1091
+ units: CliOutputUnit[],
1092
+ options?: {
1093
+ includeTypes?: CliOutputUnitType[];
1094
+ excludeTypes?: CliOutputUnitType[];
1095
+ includeTimestamps?: boolean;
1096
+ separator?: string;
1097
+ }
1098
+ ): string {
1099
+ const {
1100
+ includeTypes,
1101
+ excludeTypes,
1102
+ includeTimestamps = false,
1103
+ separator = '\n'
1104
+ } = options || {};
1105
+
1106
+ // Filter units by type
1107
+ let filtered = units;
1108
+ if (includeTypes && includeTypes.length > 0) {
1109
+ filtered = filtered.filter(u => includeTypes.includes(u.type));
1110
+ }
1111
+ if (excludeTypes && excludeTypes.length > 0) {
1112
+ filtered = filtered.filter(u => !excludeTypes.includes(u.type));
1113
+ }
1114
+
1115
+ // Convert to text
1116
+ const lines = filtered.map(unit => {
1117
+ let text = '';
1118
+
1119
+ if (includeTimestamps) {
1120
+ text += `[${unit.timestamp}] `;
1121
+ }
1122
+
1123
+ // Extract text content based on type
1124
+ if (typeof unit.content === 'string') {
1125
+ text += unit.content;
1126
+ } else if (typeof unit.content === 'object' && unit.content !== null) {
1127
+ // Handle structured content with type-specific formatting
1128
+ switch (unit.type) {
1129
+ case 'file_diff':
1130
+ // Format file diff with path and diff content
1131
+ text += `File: ${unit.content.path}\n\`\`\`diff\n${unit.content.diff}\n\`\`\``;
1132
+ break;
1133
+
1134
+ case 'code':
1135
+ // Format code block with language
1136
+ const lang = unit.content.language || '';
1137
+ const code = unit.content.code || unit.content;
1138
+ text += `\`\`\`${lang}\n${typeof code === 'string' ? code : JSON.stringify(code)}\n\`\`\``;
1139
+ break;
1140
+
1141
+ case 'thought':
1142
+ // Format thought/reasoning content
1143
+ text += `[Thought] ${typeof unit.content === 'string' ? unit.content : JSON.stringify(unit.content)}`;
1144
+ break;
1145
+
1146
+ case 'progress':
1147
+ // Format progress updates
1148
+ if (unit.content.message) {
1149
+ text += unit.content.message;
1150
+ if (unit.content.progress !== undefined && unit.content.total !== undefined) {
1151
+ text += ` (${unit.content.progress}/${unit.content.total})`;
1152
+ }
1153
+ } else {
1154
+ text += JSON.stringify(unit.content);
1155
+ }
1156
+ break;
1157
+
1158
+ case 'tool_call':
1159
+ // Format tool call/result
1160
+ if (unit.content.action === 'invoke') {
1161
+ const params = unit.content.parameters ? JSON.stringify(unit.content.parameters) : '';
1162
+ text += `[Tool] ${unit.content.toolName}(${params})`;
1163
+ } else if (unit.content.action === 'result') {
1164
+ const status = unit.content.status || 'unknown';
1165
+ const output = unit.content.output ? `: ${unit.content.output.substring(0, 200)}${unit.content.output.length > 200 ? '...' : ''}` : '';
1166
+ text += `[Tool Result] ${status}${output}`;
1167
+ } else {
1168
+ text += JSON.stringify(unit.content);
1169
+ }
1170
+ break;
1171
+
1172
+ case 'metadata':
1173
+ case 'system':
1174
+ // Metadata and system events are typically excluded from prompt context
1175
+ // Include minimal representation if they passed filtering
1176
+ text += JSON.stringify(unit.content);
1177
+ break;
1178
+
1179
+ default:
1180
+ // Fallback for unknown structured types
1181
+ text += JSON.stringify(unit.content);
1182
+ }
1183
+ } else {
1184
+ text += String(unit.content);
1185
+ }
1186
+
1187
+ return text;
1188
+ });
1189
+
1190
+ return lines.join(separator);
1191
+ }
1192
+
1193
+ /**
1194
+ * Extract specific content type from units
1195
+ * Convenience helper for common extraction patterns
1196
+ */
1197
+ export function extractContent(
1198
+ units: CliOutputUnit[],
1199
+ type: CliOutputUnitType
1200
+ ): string[] {
1201
+ return units
1202
+ .filter(u => u.type === type)
1203
+ .map(u => typeof u.content === 'string' ? u.content : JSON.stringify(u.content));
1204
+ }
1205
+
1206
+ /**
1207
+ * Get statistics about output units
1208
+ * Useful for debugging and analytics
1209
+ */
1210
+ export function getOutputStats(units: CliOutputUnit[]): {
1211
+ total: number;
1212
+ byType: Record<CliOutputUnitType, number>;
1213
+ firstTimestamp?: string;
1214
+ lastTimestamp?: string;
1215
+ } {
1216
+ const byType: Record<string, number> = {};
1217
+ let firstTimestamp: string | undefined;
1218
+ let lastTimestamp: string | undefined;
1219
+
1220
+ for (const unit of units) {
1221
+ byType[unit.type] = (byType[unit.type] || 0) + 1;
1222
+
1223
+ if (!firstTimestamp || unit.timestamp < firstTimestamp) {
1224
+ firstTimestamp = unit.timestamp;
1225
+ }
1226
+ if (!lastTimestamp || unit.timestamp > lastTimestamp) {
1227
+ lastTimestamp = unit.timestamp;
1228
+ }
1229
+ }
1230
+
1231
+ return {
1232
+ total: units.length,
1233
+ byType: byType as Record<CliOutputUnitType, number>,
1234
+ firstTimestamp,
1235
+ lastTimestamp
1236
+ };
1237
+ }