@shepai/cli 1.180.0 → 1.181.0-pr539.0993dc0

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 (316) hide show
  1. package/apis/json-schema/CavemanModeConfig.yaml +14 -0
  2. package/apis/json-schema/PhaseTiming.yaml +30 -0
  3. package/apis/json-schema/SubprocessFilterConfig.yaml +11 -0
  4. package/apis/json-schema/TokenOptimizationConfig.yaml +36 -0
  5. package/apis/json-schema/WorkflowConfig.yaml +9 -0
  6. package/dist/packages/core/src/application/ports/output/agents/agent-executor.interface.d.ts +8 -0
  7. package/dist/packages/core/src/application/ports/output/agents/agent-executor.interface.d.ts.map +1 -1
  8. package/dist/packages/core/src/application/ports/output/agents/phase-timing-repository.interface.d.ts +8 -1
  9. package/dist/packages/core/src/application/ports/output/agents/phase-timing-repository.interface.d.ts.map +1 -1
  10. package/dist/packages/core/src/application/ports/output/index.d.ts +1 -1
  11. package/dist/packages/core/src/application/ports/output/index.d.ts.map +1 -1
  12. package/dist/packages/core/src/application/ports/output/services/alias-compression.interface.d.ts +45 -0
  13. package/dist/packages/core/src/application/ports/output/services/alias-compression.interface.d.ts.map +1 -0
  14. package/dist/packages/core/src/application/ports/output/services/alias-compression.interface.js +13 -0
  15. package/dist/packages/core/src/application/ports/output/services/command-output-filter.interface.d.ts +50 -0
  16. package/dist/packages/core/src/application/ports/output/services/command-output-filter.interface.d.ts.map +1 -0
  17. package/dist/packages/core/src/application/ports/output/services/command-output-filter.interface.js +13 -0
  18. package/dist/packages/core/src/application/ports/output/services/delta-context.interface.d.ts +57 -0
  19. package/dist/packages/core/src/application/ports/output/services/delta-context.interface.d.ts.map +1 -0
  20. package/dist/packages/core/src/application/ports/output/services/delta-context.interface.js +13 -0
  21. package/dist/packages/core/src/application/ports/output/services/index.d.ts +7 -0
  22. package/dist/packages/core/src/application/ports/output/services/index.d.ts.map +1 -1
  23. package/dist/packages/core/src/application/ports/output/services/optimization-metrics.interface.d.ts +45 -0
  24. package/dist/packages/core/src/application/ports/output/services/optimization-metrics.interface.d.ts.map +1 -0
  25. package/dist/packages/core/src/application/ports/output/services/optimization-metrics.interface.js +13 -0
  26. package/dist/packages/core/src/application/ports/output/services/prompt-optimizer.interface.d.ts +86 -0
  27. package/dist/packages/core/src/application/ports/output/services/prompt-optimizer.interface.d.ts.map +1 -0
  28. package/dist/packages/core/src/application/ports/output/services/prompt-optimizer.interface.js +13 -0
  29. package/dist/packages/core/src/application/ports/output/services/semantic-compressor.interface.d.ts +43 -0
  30. package/dist/packages/core/src/application/ports/output/services/semantic-compressor.interface.d.ts.map +1 -0
  31. package/dist/packages/core/src/application/ports/output/services/semantic-compressor.interface.js +13 -0
  32. package/dist/packages/core/src/application/ports/output/services/skill-routing.interface.d.ts +41 -0
  33. package/dist/packages/core/src/application/ports/output/services/skill-routing.interface.d.ts.map +1 -0
  34. package/dist/packages/core/src/application/ports/output/services/skill-routing.interface.js +12 -0
  35. package/dist/packages/core/src/domain/factories/settings-defaults.factory.d.ts.map +1 -1
  36. package/dist/packages/core/src/domain/factories/settings-defaults.factory.js +21 -0
  37. package/dist/packages/core/src/domain/generated/output.d.ts +95 -0
  38. package/dist/packages/core/src/domain/generated/output.d.ts.map +1 -1
  39. package/dist/packages/core/src/infrastructure/di/container.d.ts.map +1 -1
  40. package/dist/packages/core/src/infrastructure/di/container.js +27 -0
  41. package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.d.ts +9 -0
  42. package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.d.ts.map +1 -1
  43. package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.js +68 -0
  44. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/055-add-token-optimization-config.d.ts +29 -0
  45. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/055-add-token-optimization-config.d.ts.map +1 -0
  46. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/055-add-token-optimization-config.js +77 -0
  47. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/056-add-caveman-mode-config.d.ts +21 -0
  48. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/056-add-caveman-mode-config.d.ts.map +1 -0
  49. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/056-add-caveman-mode-config.js +29 -0
  50. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/057-add-subprocess-filter-config.d.ts +17 -0
  51. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/057-add-subprocess-filter-config.d.ts.map +1 -0
  52. package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/057-add-subprocess-filter-config.js +22 -0
  53. package/dist/packages/core/src/infrastructure/repositories/sqlite-phase-timing.repository.d.ts +2 -1
  54. package/dist/packages/core/src/infrastructure/repositories/sqlite-phase-timing.repository.d.ts.map +1 -1
  55. package/dist/packages/core/src/infrastructure/repositories/sqlite-phase-timing.repository.js +72 -0
  56. package/dist/packages/core/src/infrastructure/repositories/sqlite-settings.repository.d.ts.map +1 -1
  57. package/dist/packages/core/src/infrastructure/repositories/sqlite-settings.repository.js +19 -3
  58. package/dist/packages/core/src/infrastructure/services/agents/analyze-repo/analyze-repository-graph.d.ts +1 -1
  59. package/dist/packages/core/src/infrastructure/services/agents/common/executors/claude-code-executor.service.d.ts.map +1 -1
  60. package/dist/packages/core/src/infrastructure/services/agents/common/executors/claude-code-executor.service.js +9 -0
  61. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/caveman-directive.d.ts +41 -0
  62. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/caveman-directive.d.ts.map +1 -0
  63. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/caveman-directive.js +51 -0
  64. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/fast-feature-agent-graph.d.ts +6 -1
  65. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/fast-feature-agent-graph.d.ts.map +1 -1
  66. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-graph.d.ts +18 -1
  67. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-graph.d.ts.map +1 -1
  68. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-worker.d.ts.map +1 -1
  69. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/feature-agent-worker.js +6 -0
  70. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence.node.d.ts.map +1 -1
  71. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/evidence.node.js +2 -2
  72. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/fast-implement.node.d.ts.map +1 -1
  73. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/fast-implement.node.js +3 -2
  74. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/implement.node.d.ts.map +1 -1
  75. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/implement.node.js +5 -4
  76. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/merge/merge.node.d.ts.map +1 -1
  77. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/merge/merge.node.js +3 -4
  78. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/node-helpers.d.ts +27 -0
  79. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/node-helpers.d.ts.map +1 -1
  80. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/node-helpers.js +71 -1
  81. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/prompt-optimization-context.d.ts +42 -0
  82. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/prompt-optimization-context.d.ts.map +1 -0
  83. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/prompt-optimization-context.js +92 -0
  84. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/state.d.ts +1 -0
  85. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/state.d.ts.map +1 -1
  86. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/state.js +5 -0
  87. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/subprocess-filter-context.d.ts +25 -0
  88. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/subprocess-filter-context.d.ts.map +1 -0
  89. package/dist/packages/core/src/infrastructure/services/agents/feature-agent/subprocess-filter-context.js +67 -0
  90. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/generic-filter.d.ts +13 -0
  91. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/generic-filter.d.ts.map +1 -0
  92. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/generic-filter.js +21 -0
  93. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/git-filter.d.ts +15 -0
  94. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/git-filter.d.ts.map +1 -0
  95. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/git-filter.js +189 -0
  96. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/npm-filter.d.ts +13 -0
  97. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/npm-filter.d.ts.map +1 -0
  98. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/npm-filter.js +96 -0
  99. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/shared-helpers.d.ts +29 -0
  100. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/shared-helpers.d.ts.map +1 -0
  101. package/dist/packages/core/src/infrastructure/services/subprocess-filter/filters/shared-helpers.js +85 -0
  102. package/dist/packages/core/src/infrastructure/services/subprocess-filter/shep-filter.d.ts +27 -0
  103. package/dist/packages/core/src/infrastructure/services/subprocess-filter/shep-filter.d.ts.map +1 -0
  104. package/dist/packages/core/src/infrastructure/services/subprocess-filter/shep-filter.js +89 -0
  105. package/dist/packages/core/src/infrastructure/services/subprocess-filter/shim-generator.d.ts +39 -0
  106. package/dist/packages/core/src/infrastructure/services/subprocess-filter/shim-generator.d.ts.map +1 -0
  107. package/dist/packages/core/src/infrastructure/services/subprocess-filter/shim-generator.js +53 -0
  108. package/dist/packages/core/src/infrastructure/services/token-optimization/alias-compression.service.d.ts +41 -0
  109. package/dist/packages/core/src/infrastructure/services/token-optimization/alias-compression.service.d.ts.map +1 -0
  110. package/dist/packages/core/src/infrastructure/services/token-optimization/alias-compression.service.js +111 -0
  111. package/dist/packages/core/src/infrastructure/services/token-optimization/command-output-filter.service.d.ts +22 -0
  112. package/dist/packages/core/src/infrastructure/services/token-optimization/command-output-filter.service.d.ts.map +1 -0
  113. package/dist/packages/core/src/infrastructure/services/token-optimization/command-output-filter.service.js +245 -0
  114. package/dist/packages/core/src/infrastructure/services/token-optimization/delta-context.service.d.ts +22 -0
  115. package/dist/packages/core/src/infrastructure/services/token-optimization/delta-context.service.d.ts.map +1 -0
  116. package/dist/packages/core/src/infrastructure/services/token-optimization/delta-context.service.js +50 -0
  117. package/dist/packages/core/src/infrastructure/services/token-optimization/optimization-metrics.service.d.ts +36 -0
  118. package/dist/packages/core/src/infrastructure/services/token-optimization/optimization-metrics.service.d.ts.map +1 -0
  119. package/dist/packages/core/src/infrastructure/services/token-optimization/optimization-metrics.service.js +123 -0
  120. package/dist/packages/core/src/infrastructure/services/token-optimization/prompt-optimizer.service.d.ts +57 -0
  121. package/dist/packages/core/src/infrastructure/services/token-optimization/prompt-optimizer.service.d.ts.map +1 -0
  122. package/dist/packages/core/src/infrastructure/services/token-optimization/prompt-optimizer.service.js +241 -0
  123. package/dist/packages/core/src/infrastructure/services/token-optimization/semantic-compressor.service.d.ts +34 -0
  124. package/dist/packages/core/src/infrastructure/services/token-optimization/semantic-compressor.service.d.ts.map +1 -0
  125. package/dist/packages/core/src/infrastructure/services/token-optimization/semantic-compressor.service.js +190 -0
  126. package/dist/packages/core/src/infrastructure/services/token-optimization/skill-routing.service.d.ts +26 -0
  127. package/dist/packages/core/src/infrastructure/services/token-optimization/skill-routing.service.d.ts.map +1 -0
  128. package/dist/packages/core/src/infrastructure/services/token-optimization/skill-routing.service.js +51 -0
  129. package/dist/tsconfig.build.tsbuildinfo +1 -1
  130. package/package.json +1 -1
  131. package/web/.next/BUILD_ID +1 -1
  132. package/web/.next/build-manifest.json +2 -2
  133. package/web/.next/fallback-build-manifest.json +2 -2
  134. package/web/.next/prerender-manifest.json +3 -3
  135. package/web/.next/required-server-files.js +3 -3
  136. package/web/.next/required-server-files.json +3 -3
  137. package/web/.next/server/app/(dashboard)/@drawer/adopt/page/server-reference-manifest.json +32 -32
  138. package/web/.next/server/app/(dashboard)/@drawer/adopt/page.js.nft.json +1 -1
  139. package/web/.next/server/app/(dashboard)/@drawer/adopt/page_client-reference-manifest.js +1 -1
  140. package/web/.next/server/app/(dashboard)/@drawer/chat/page/server-reference-manifest.json +30 -30
  141. package/web/.next/server/app/(dashboard)/@drawer/chat/page.js.nft.json +1 -1
  142. package/web/.next/server/app/(dashboard)/@drawer/chat/page_client-reference-manifest.js +1 -1
  143. package/web/.next/server/app/(dashboard)/@drawer/create/page/server-reference-manifest.json +33 -33
  144. package/web/.next/server/app/(dashboard)/@drawer/create/page.js.nft.json +1 -1
  145. package/web/.next/server/app/(dashboard)/@drawer/create/page_client-reference-manifest.js +1 -1
  146. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page/server-reference-manifest.json +41 -41
  147. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  148. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  149. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page/server-reference-manifest.json +41 -41
  150. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page.js.nft.json +1 -1
  151. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page_client-reference-manifest.js +1 -1
  152. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page/server-reference-manifest.json +31 -31
  153. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page.js.nft.json +1 -1
  154. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page_client-reference-manifest.js +1 -1
  155. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page/server-reference-manifest.json +31 -31
  156. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page.js.nft.json +1 -1
  157. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  158. package/web/.next/server/app/(dashboard)/chat/page/server-reference-manifest.json +30 -30
  159. package/web/.next/server/app/(dashboard)/chat/page.js.nft.json +1 -1
  160. package/web/.next/server/app/(dashboard)/chat/page_client-reference-manifest.js +1 -1
  161. package/web/.next/server/app/(dashboard)/create/page/server-reference-manifest.json +33 -33
  162. package/web/.next/server/app/(dashboard)/create/page.js.nft.json +1 -1
  163. package/web/.next/server/app/(dashboard)/create/page_client-reference-manifest.js +1 -1
  164. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page/server-reference-manifest.json +41 -41
  165. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  166. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  167. package/web/.next/server/app/(dashboard)/feature/[featureId]/page/server-reference-manifest.json +41 -41
  168. package/web/.next/server/app/(dashboard)/feature/[featureId]/page.js.nft.json +1 -1
  169. package/web/.next/server/app/(dashboard)/feature/[featureId]/page_client-reference-manifest.js +1 -1
  170. package/web/.next/server/app/(dashboard)/page/server-reference-manifest.json +30 -30
  171. package/web/.next/server/app/(dashboard)/page.js.nft.json +1 -1
  172. package/web/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  173. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page/server-reference-manifest.json +31 -31
  174. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page.js.nft.json +1 -1
  175. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page_client-reference-manifest.js +1 -1
  176. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page/server-reference-manifest.json +31 -31
  177. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page.js.nft.json +1 -1
  178. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  179. package/web/.next/server/app/_global-error.html +2 -2
  180. package/web/.next/server/app/_global-error.rsc +1 -1
  181. package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  182. package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  183. package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  184. package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  185. package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  186. package/web/.next/server/app/_not-found/page/server-reference-manifest.json +7 -7
  187. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  188. package/web/.next/server/app/application/[id]/page/server-reference-manifest.json +15 -15
  189. package/web/.next/server/app/application/[id]/page.js.nft.json +1 -1
  190. package/web/.next/server/app/application/[id]/page_client-reference-manifest.js +1 -1
  191. package/web/.next/server/app/features/page/server-reference-manifest.json +7 -7
  192. package/web/.next/server/app/features/page_client-reference-manifest.js +1 -1
  193. package/web/.next/server/app/settings/page/server-reference-manifest.json +10 -10
  194. package/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  195. package/web/.next/server/app/skills/page/server-reference-manifest.json +15 -15
  196. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  197. package/web/.next/server/app/tools/page/server-reference-manifest.json +13 -13
  198. package/web/.next/server/app/tools/page_client-reference-manifest.js +1 -1
  199. package/web/.next/server/app/version/page/server-reference-manifest.json +7 -7
  200. package/web/.next/server/app/version/page_client-reference-manifest.js +1 -1
  201. package/web/.next/server/chunks/[root-of-the-server]__a402b567._.js +1 -1
  202. package/web/.next/server/chunks/[root-of-the-server]__b2a4bfcc._.js.map +1 -1
  203. package/web/.next/server/chunks/[root-of-the-server]__cd67a84c._.js.map +1 -1
  204. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js +1 -1
  205. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js.map +1 -1
  206. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_feature-drawer-client_tsx_e9755fc8._.js +2 -2
  207. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_feature-drawer-client_tsx_e9755fc8._.js.map +1 -1
  208. package/web/.next/server/chunks/ssr/[root-of-the-server]__013a0318._.js +1 -1
  209. package/web/.next/server/chunks/ssr/[root-of-the-server]__013a0318._.js.map +1 -1
  210. package/web/.next/server/chunks/ssr/[root-of-the-server]__17dadd08._.js +1 -1
  211. package/web/.next/server/chunks/ssr/[root-of-the-server]__17dadd08._.js.map +1 -1
  212. package/web/.next/server/chunks/ssr/[root-of-the-server]__1925bef0._.js +1 -1
  213. package/web/.next/server/chunks/ssr/[root-of-the-server]__1a9687c4._.js +1 -1
  214. package/web/.next/server/chunks/ssr/[root-of-the-server]__1a9687c4._.js.map +1 -1
  215. package/web/.next/server/chunks/ssr/[root-of-the-server]__24756fa9._.js +2 -2
  216. package/web/.next/server/chunks/ssr/[root-of-the-server]__24756fa9._.js.map +1 -1
  217. package/web/.next/server/chunks/ssr/[root-of-the-server]__4ee8be85._.js +1 -1
  218. package/web/.next/server/chunks/ssr/[root-of-the-server]__70986695._.js +1 -1
  219. package/web/.next/server/chunks/ssr/[root-of-the-server]__70986695._.js.map +1 -1
  220. package/web/.next/server/chunks/ssr/[root-of-the-server]__a5ea76a6._.js +1 -1
  221. package/web/.next/server/chunks/ssr/[root-of-the-server]__a5ea76a6._.js.map +1 -1
  222. package/web/.next/server/chunks/ssr/[root-of-the-server]__bb391c45._.js +1 -1
  223. package/web/.next/server/chunks/ssr/[root-of-the-server]__bb391c45._.js.map +1 -1
  224. package/web/.next/server/chunks/ssr/[root-of-the-server]__dd3e834e._.js +1 -1
  225. package/web/.next/server/chunks/ssr/[root-of-the-server]__dd3e834e._.js.map +1 -1
  226. package/web/.next/server/chunks/ssr/[root-of-the-server]__e265da61._.js +1 -1
  227. package/web/.next/server/chunks/ssr/[root-of-the-server]__f3ca7bea._.js +1 -1
  228. package/web/.next/server/chunks/ssr/[root-of-the-server]__f3ca7bea._.js.map +1 -1
  229. package/web/.next/server/chunks/ssr/_0277d3b5._.js +1 -1
  230. package/web/.next/server/chunks/ssr/_0277d3b5._.js.map +1 -1
  231. package/web/.next/server/chunks/ssr/_295fffde._.js.map +1 -1
  232. package/web/.next/server/chunks/ssr/_45496654._.js.map +1 -1
  233. package/web/.next/server/chunks/ssr/_56b9d60f._.js +1 -1
  234. package/web/.next/server/chunks/ssr/_56b9d60f._.js.map +1 -1
  235. package/web/.next/server/chunks/ssr/{_8caadb9a._.js → _688e1fd9._.js} +2 -2
  236. package/web/.next/server/chunks/ssr/{_8caadb9a._.js.map → _688e1fd9._.js.map} +1 -1
  237. package/web/.next/server/chunks/ssr/_7931d3de._.js +3 -0
  238. package/web/.next/server/chunks/ssr/{_36489f2b._.js.map → _7931d3de._.js.map} +1 -1
  239. package/web/.next/server/chunks/ssr/_946a7fc6._.js +1 -1
  240. package/web/.next/server/chunks/ssr/_946a7fc6._.js.map +1 -1
  241. package/web/.next/server/chunks/ssr/{_d44d091a._.js → _bd8c6d0b._.js} +2 -2
  242. package/web/.next/server/chunks/ssr/{_d44d091a._.js.map → _bd8c6d0b._.js.map} +1 -1
  243. package/web/.next/server/chunks/ssr/{_63fc4647._.js → _ce7571dd._.js} +2 -2
  244. package/web/.next/server/chunks/ssr/{_63fc4647._.js.map → _ce7571dd._.js.map} +1 -1
  245. package/web/.next/server/chunks/ssr/_eff1b518._.js +1 -1
  246. package/web/.next/server/chunks/ssr/_eff1b518._.js.map +1 -1
  247. package/web/.next/server/chunks/ssr/_f227429a._.js +1 -1
  248. package/web/.next/server/chunks/ssr/_f227429a._.js.map +1 -1
  249. package/web/.next/server/chunks/ssr/_f5a56a3f._.js +3 -0
  250. package/web/.next/server/chunks/ssr/{_b8e8b690._.js.map → _f5a56a3f._.js.map} +1 -1
  251. package/web/.next/server/chunks/ssr/_f86fc1bf._.js +1 -1
  252. package/web/.next/server/chunks/ssr/_f86fc1bf._.js.map +1 -1
  253. package/web/.next/server/chunks/ssr/_f8c55130._.js +1 -1
  254. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js +1 -1
  255. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js.map +1 -1
  256. package/web/.next/server/chunks/ssr/f3a1f_components_common_control-center-drawer_repository-drawer-client_tsx_39a00c03._.js +1 -1
  257. package/web/.next/server/chunks/ssr/src_presentation_web_36f2bc45._.js +1 -1
  258. package/web/.next/server/chunks/ssr/src_presentation_web_36f2bc45._.js.map +1 -1
  259. package/web/.next/server/chunks/ssr/src_presentation_web_486908de._.js +1 -1
  260. package/web/.next/server/chunks/ssr/src_presentation_web_486908de._.js.map +1 -1
  261. package/web/.next/server/chunks/ssr/src_presentation_web_5c3596bc._.js +1 -1
  262. package/web/.next/server/chunks/ssr/src_presentation_web_5c3596bc._.js.map +1 -1
  263. package/web/.next/server/chunks/ssr/src_presentation_web_6159fef8._.js +1 -1
  264. package/web/.next/server/chunks/ssr/src_presentation_web_6159fef8._.js.map +1 -1
  265. package/web/.next/server/chunks/ssr/src_presentation_web_6326f81e._.js +1 -1
  266. package/web/.next/server/chunks/ssr/src_presentation_web_6326f81e._.js.map +1 -1
  267. package/web/.next/server/chunks/ssr/src_presentation_web_6b2fdcd8._.js +1 -1
  268. package/web/.next/server/chunks/ssr/src_presentation_web_6b2fdcd8._.js.map +1 -1
  269. package/web/.next/server/chunks/ssr/src_presentation_web_74703c9f._.js +1 -1
  270. package/web/.next/server/chunks/ssr/src_presentation_web_74703c9f._.js.map +1 -1
  271. package/web/.next/server/chunks/ssr/src_presentation_web_a8056dac._.js +1 -1
  272. package/web/.next/server/chunks/ssr/src_presentation_web_a8056dac._.js.map +1 -1
  273. package/web/.next/server/chunks/ssr/src_presentation_web_ad42cc73._.js +1 -1
  274. package/web/.next/server/chunks/ssr/src_presentation_web_ad42cc73._.js.map +1 -1
  275. package/web/.next/server/chunks/ssr/src_presentation_web_app_actions_open-ide_ts_baaca5d5._.js +3 -3
  276. package/web/.next/server/chunks/ssr/src_presentation_web_b00bfb08._.js +1 -1
  277. package/web/.next/server/chunks/ssr/src_presentation_web_b00bfb08._.js.map +1 -1
  278. package/web/.next/server/chunks/ssr/src_presentation_web_components_895e5bfa._.js +1 -1
  279. package/web/.next/server/chunks/ssr/src_presentation_web_components_895e5bfa._.js.map +1 -1
  280. package/web/.next/server/chunks/ssr/src_presentation_web_components_common_base-drawer_base-drawer_tsx_97dfbbc8._.js +1 -1
  281. package/web/.next/server/chunks/ssr/src_presentation_web_components_common_base-drawer_base-drawer_tsx_97dfbbc8._.js.map +1 -1
  282. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js +1 -1
  283. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js.map +1 -1
  284. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_skills_8a174cac._.js +1 -1
  285. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_skills_8a174cac._.js.map +1 -1
  286. package/web/.next/server/chunks/ssr/src_presentation_web_db9fa0c2._.js +1 -1
  287. package/web/.next/server/chunks/ssr/src_presentation_web_db9fa0c2._.js.map +1 -1
  288. package/web/.next/server/chunks/ssr/src_presentation_web_f1edcf5e._.js +1 -1
  289. package/web/.next/server/chunks/ssr/src_presentation_web_f1edcf5e._.js.map +1 -1
  290. package/web/.next/server/chunks/ssr/src_presentation_web_f9436804._.js +1 -1
  291. package/web/.next/server/chunks/ssr/src_presentation_web_f9436804._.js.map +1 -1
  292. package/web/.next/server/pages/500.html +2 -2
  293. package/web/.next/server/server-reference-manifest.js +1 -1
  294. package/web/.next/server/server-reference-manifest.json +54 -54
  295. package/web/.next/static/chunks/{f6d47ff35d612852.js → 2bba4ee52a6464cd.js} +3 -3
  296. package/web/.next/static/chunks/4371be9a949c8fe0.js +1 -0
  297. package/web/.next/static/chunks/{490667b2a9bb58e2.js → 46bc202f80905332.js} +1 -1
  298. package/web/.next/static/chunks/{26e2ca76ab6c38b4.js → 51593e45475cb81d.js} +1 -1
  299. package/web/.next/static/chunks/{c0bd3ffcf94d1845.js → 75d1485ec29b8fd8.js} +1 -1
  300. package/web/.next/static/chunks/{e7da54dde18e7fb2.js → aba1ec85581d3f1b.js} +1 -1
  301. package/web/.next/static/chunks/{e2f9e224d1fa1faa.js → abc53f1cc59f4642.js} +1 -1
  302. package/web/.next/static/chunks/{a1098522326428d1.js → ac069319b2aeab27.js} +1 -1
  303. package/web/.next/static/chunks/{1fa1574b87bd2eb1.js → b5aadaa3b34d7b8e.js} +1 -1
  304. package/web/.next/static/chunks/{dfdcccf73de56960.js → b7e697748c35a4ce.js} +1 -1
  305. package/web/.next/static/chunks/{7849c6797be7c6ca.js → b9135c0d88735f54.js} +2 -2
  306. package/web/.next/static/chunks/{893a2a76546c66a7.js → c6b5b3f46622241d.js} +1 -1
  307. package/web/.next/static/chunks/{f28aef9cf5107c4b.js → c9c58949bf064dbe.js} +1 -1
  308. package/web/.next/static/chunks/{be89c20c257247ad.js → cbf7498ef586ebd3.js} +1 -1
  309. package/web/.next/static/chunks/{8746807722de67a8.js → d9f55661eb505770.js} +1 -1
  310. package/web/.next/static/chunks/{7bc7028587490fff.js → e3d4828e3b7291df.js} +1 -1
  311. package/web/.next/server/chunks/ssr/_36489f2b._.js +0 -3
  312. package/web/.next/server/chunks/ssr/_b8e8b690._.js +0 -3
  313. package/web/.next/static/chunks/1bc12075020723ed.js +0 -1
  314. /package/web/.next/static/{GQFJf3UCD4D5C4NCn8eXl → 73VlrUiVfmfr0uTiP1eN1}/_buildManifest.js +0 -0
  315. /package/web/.next/static/{GQFJf3UCD4D5C4NCn8eXl → 73VlrUiVfmfr0uTiP1eN1}/_clientMiddlewareManifest.json +0 -0
  316. /package/web/.next/static/{GQFJf3UCD4D5C4NCn8eXl → 73VlrUiVfmfr0uTiP1eN1}/_ssgManifest.js +0 -0
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Prompt Optimization Context
3
+ *
4
+ * Module-level singleton that exposes the token-optimization layer to
5
+ * executeNode() in node-helpers.ts without changing its public API.
6
+ *
7
+ * The worker calls setPromptOptimizationContext() once after DI init.
8
+ * Node helpers call optimizePromptIfEnabled() before invoking the agent
9
+ * executor and recordOptimizationMetricsIfEnabled() after the phase
10
+ * timing record is updated.
11
+ *
12
+ * Errors are swallowed so optimization failures never block graph execution.
13
+ */
14
+ import { hasSettings, getSettings } from '../../../services/settings.service.js';
15
+ let contextOptimizer;
16
+ let contextMetricsService;
17
+ let contextRunId;
18
+ let contextFeatureId;
19
+ /**
20
+ * Set the prompt-optimization context. Called once by the worker after DI init.
21
+ */
22
+ export function setPromptOptimizationContext(optimizer, metricsService, runId, featureId) {
23
+ contextOptimizer = optimizer;
24
+ contextMetricsService = metricsService;
25
+ contextRunId = runId;
26
+ contextFeatureId = featureId;
27
+ }
28
+ /**
29
+ * Clear the prompt-optimization context. Useful for testing.
30
+ */
31
+ export function clearPromptOptimizationContext() {
32
+ contextOptimizer = undefined;
33
+ contextMetricsService = undefined;
34
+ contextRunId = undefined;
35
+ contextFeatureId = undefined;
36
+ }
37
+ /**
38
+ * Resolve the effective TokenOptimizationConfig from settings. Returns
39
+ * undefined if settings are not initialized.
40
+ */
41
+ function resolveConfig() {
42
+ if (!hasSettings())
43
+ return undefined;
44
+ return getSettings().workflow?.tokenOptimization;
45
+ }
46
+ /**
47
+ * Optimize the given prompt if the optimizer context is set and the
48
+ * master toggle is enabled. Falls back to a passthrough result on any
49
+ * error so node execution is never blocked by optimization failures.
50
+ */
51
+ export async function optimizePromptIfEnabled(prompt, phaseName, modelId, previousSpecFileHashes) {
52
+ if (!contextOptimizer || !contextRunId || !contextFeatureId) {
53
+ return { prompt, metrics: null, specFileHashes: previousSpecFileHashes ?? {} };
54
+ }
55
+ const config = resolveConfig();
56
+ if (!config?.enabled) {
57
+ return { prompt, metrics: null, specFileHashes: previousSpecFileHashes ?? {} };
58
+ }
59
+ try {
60
+ const result = await contextOptimizer.optimize(prompt, {
61
+ phaseName,
62
+ modelId,
63
+ featureId: contextFeatureId,
64
+ agentRunId: contextRunId,
65
+ previousSpecFileHashes,
66
+ config,
67
+ });
68
+ return {
69
+ prompt: result.prompt,
70
+ metrics: result.metrics,
71
+ specFileHashes: result.specFileHashes,
72
+ };
73
+ }
74
+ catch {
75
+ // Swallow — optimization failure must never block phase execution
76
+ return { prompt, metrics: null, specFileHashes: previousSpecFileHashes ?? {} };
77
+ }
78
+ }
79
+ /**
80
+ * Persist optimization metrics on the given phase timing row.
81
+ * No-op if context is not set, timingId is null, or metrics are null.
82
+ */
83
+ export async function recordOptimizationMetricsIfEnabled(timingId, metrics) {
84
+ if (!contextMetricsService || !timingId || !metrics)
85
+ return;
86
+ try {
87
+ await contextMetricsService.record(timingId, metrics);
88
+ }
89
+ catch {
90
+ // Swallow — metrics persistence failure is non-fatal
91
+ }
92
+ }
@@ -59,6 +59,7 @@ export declare const FeatureAgentAnnotation: import("@langchain/langgraph").Anno
59
59
  ciFixAttempts: import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
60
60
  ciFixHistory: import("@langchain/langgraph").BinaryOperatorAggregate<CiFixRecord[], CiFixRecord[]>;
61
61
  ciFixStatus: import("@langchain/langgraph").BinaryOperatorAggregate<"success" | "timeout" | "idle" | "watching" | "fixing" | "exhausted", "success" | "timeout" | "idle" | "watching" | "fixing" | "exhausted">;
62
+ specFileHashes: import("@langchain/langgraph").BinaryOperatorAggregate<Record<string, string>, Record<string, string>>;
62
63
  }>;
63
64
  export type FeatureAgentState = typeof FeatureAgentAnnotation.State;
64
65
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/src/infrastructure/services/agents/feature-agent/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAEzF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwHjC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,OAAO,sBAAsB,CAAC,KAAK,CAAC"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/src/infrastructure/services/agents/feature-agent/state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAEzF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6HjC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,OAAO,sBAAsB,CAAC,KAAK,CAAC"}
@@ -126,4 +126,9 @@ export const FeatureAgentAnnotation = Annotation.Root({
126
126
  reducer: (_prev, next) => next,
127
127
  default: () => 'idle',
128
128
  }),
129
+ // --- Token optimization state ---
130
+ specFileHashes: Annotation({
131
+ reducer: (_prev, next) => next,
132
+ default: () => ({}),
133
+ }),
129
134
  });
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Subprocess Filter Context
3
+ *
4
+ * Lazily creates and caches a shim directory for the lifetime of the
5
+ * worker process. The shim dir contains wrapper scripts (git, npm,
6
+ * pnpm, yarn) that pipe command output through shep-filter before
7
+ * returning it to Claude Code.
8
+ *
9
+ * The shim dir is created once on the first call to
10
+ * resolveSubprocessFilterShimDir(true) and reused for all subsequent
11
+ * calls. It's automatically cleaned up when the worker process exits
12
+ * (via process.on('exit')).
13
+ */
14
+ /**
15
+ * Resolve the shim directory path, creating it lazily if needed.
16
+ *
17
+ * @param enabled - Whether subprocess filtering is enabled in settings
18
+ * @returns The absolute path to the shim directory, or undefined if disabled
19
+ */
20
+ export declare function resolveSubprocessFilterShimDir(enabled: boolean): string | undefined;
21
+ /**
22
+ * Clear the cached shim directory. Useful for testing.
23
+ */
24
+ export declare function clearSubprocessFilterContext(): void;
25
+ //# sourceMappingURL=subprocess-filter-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subprocess-filter-context.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/src/infrastructure/services/agents/feature-agent/subprocess-filter-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAmBH;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAmBnF;AAED;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CASnD"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Subprocess Filter Context
3
+ *
4
+ * Lazily creates and caches a shim directory for the lifetime of the
5
+ * worker process. The shim dir contains wrapper scripts (git, npm,
6
+ * pnpm, yarn) that pipe command output through shep-filter before
7
+ * returning it to Claude Code.
8
+ *
9
+ * The shim dir is created once on the first call to
10
+ * resolveSubprocessFilterShimDir(true) and reused for all subsequent
11
+ * calls. It's automatically cleaned up when the worker process exits
12
+ * (via process.on('exit')).
13
+ */
14
+ import { join, dirname } from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+ import { rmSync } from 'node:fs';
17
+ import { createShimDirectory } from '../../subprocess-filter/shim-generator.js';
18
+ let cachedShimDir;
19
+ /**
20
+ * Resolve the path to the compiled shep-filter.js entry point.
21
+ * This is relative to the current file's location in the dist tree.
22
+ */
23
+ function resolveShepFilterPath() {
24
+ const thisDir = dirname(fileURLToPath(import.meta.url));
25
+ // From dist/.../agents/feature-agent/ → dist/.../subprocess-filter/shep-filter.js
26
+ return join(thisDir, '..', '..', 'subprocess-filter', 'shep-filter.js');
27
+ }
28
+ /**
29
+ * Resolve the shim directory path, creating it lazily if needed.
30
+ *
31
+ * @param enabled - Whether subprocess filtering is enabled in settings
32
+ * @returns The absolute path to the shim directory, or undefined if disabled
33
+ */
34
+ export function resolveSubprocessFilterShimDir(enabled) {
35
+ if (!enabled)
36
+ return undefined;
37
+ if (!cachedShimDir) {
38
+ const shepFilterPath = resolveShepFilterPath();
39
+ const shim = createShimDirectory(shepFilterPath);
40
+ cachedShimDir = shim.path;
41
+ // Register cleanup on process exit
42
+ process.on('exit', () => {
43
+ try {
44
+ if (cachedShimDir)
45
+ rmSync(cachedShimDir, { recursive: true, force: true });
46
+ }
47
+ catch {
48
+ // best-effort cleanup
49
+ }
50
+ });
51
+ }
52
+ return cachedShimDir;
53
+ }
54
+ /**
55
+ * Clear the cached shim directory. Useful for testing.
56
+ */
57
+ export function clearSubprocessFilterContext() {
58
+ if (cachedShimDir) {
59
+ try {
60
+ rmSync(cachedShimDir, { recursive: true, force: true });
61
+ }
62
+ catch {
63
+ // best-effort
64
+ }
65
+ }
66
+ cachedShimDir = undefined;
67
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generic output filter — fallback for commands without a dedicated
3
+ * filter. Applies ANSI stripping, blank-line collapsing, line
4
+ * deduplication, and middle-truncation.
5
+ *
6
+ * This is intentionally conservative: it never drops content that
7
+ * might be meaningful, it only compresses repeated/blank/color noise.
8
+ */
9
+ /**
10
+ * Apply generic output cleanup. Safe for any command.
11
+ */
12
+ export declare function filterGeneric(output: string): string;
13
+ //# sourceMappingURL=generic-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic-filter.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/src/infrastructure/services/subprocess-filter/filters/generic-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOpD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Generic output filter — fallback for commands without a dedicated
3
+ * filter. Applies ANSI stripping, blank-line collapsing, line
4
+ * deduplication, and middle-truncation.
5
+ *
6
+ * This is intentionally conservative: it never drops content that
7
+ * might be meaningful, it only compresses repeated/blank/color noise.
8
+ */
9
+ import { stripAnsi, collapseBlankLines, deduplicateLines, truncateMiddle, } from './shared-helpers.js';
10
+ const MAX_LINES = 150;
11
+ /**
12
+ * Apply generic output cleanup. Safe for any command.
13
+ */
14
+ export function filterGeneric(output) {
15
+ const clean = stripAnsi(output).trim();
16
+ if (clean.length === 0)
17
+ return '';
18
+ const deduped = deduplicateLines(clean);
19
+ const collapsed = collapseBlankLines(deduped);
20
+ return truncateMiddle(collapsed, MAX_LINES);
21
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Git output filter — filters the output of git subcommands to reduce
3
+ * token consumption when Claude Code ingests tool results.
4
+ *
5
+ * Covers: status, log, diff, show, add, commit, push, pull, fetch,
6
+ * branch, stash, worktree. Unrecognized subcommands fall through to
7
+ * the generic filter.
8
+ */
9
+ /**
10
+ * Filter git command output. Dispatches to a subcommand-specific
11
+ * handler when one exists, otherwise returns the input with basic
12
+ * cleanup (ANSI strip + blank collapse).
13
+ */
14
+ export declare function filterGit(subcommand: string, output: string): string;
15
+ //# sourceMappingURL=git-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-filter.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/src/infrastructure/services/subprocess-filter/filters/git-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAgCpE"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * Git output filter — filters the output of git subcommands to reduce
3
+ * token consumption when Claude Code ingests tool results.
4
+ *
5
+ * Covers: status, log, diff, show, add, commit, push, pull, fetch,
6
+ * branch, stash, worktree. Unrecognized subcommands fall through to
7
+ * the generic filter.
8
+ */
9
+ import { stripAnsi, collapseBlankLines, truncateMiddle } from './shared-helpers.js';
10
+ const MAX_DIFF_LINES = 200;
11
+ const MAX_LOG_LINES = 100;
12
+ /**
13
+ * Filter git command output. Dispatches to a subcommand-specific
14
+ * handler when one exists, otherwise returns the input with basic
15
+ * cleanup (ANSI strip + blank collapse).
16
+ */
17
+ export function filterGit(subcommand, output) {
18
+ const clean = stripAnsi(output).trimEnd();
19
+ if (clean.trim().length === 0)
20
+ return 'ok';
21
+ switch (subcommand) {
22
+ case 'status':
23
+ return filterStatus(clean);
24
+ case 'log':
25
+ return filterLog(clean);
26
+ case 'diff':
27
+ return filterDiff(clean);
28
+ case 'show':
29
+ return filterShow(clean);
30
+ case 'add':
31
+ return filterSimpleOk(clean, 'added');
32
+ case 'commit':
33
+ return filterCommit(clean);
34
+ case 'push':
35
+ return filterPush(clean);
36
+ case 'pull':
37
+ return filterPull(clean);
38
+ case 'fetch':
39
+ return filterSimpleOk(clean, 'fetched');
40
+ case 'branch':
41
+ return filterBranch(clean);
42
+ case 'stash':
43
+ return filterSimpleOk(clean, 'stash');
44
+ case 'worktree':
45
+ return collapseBlankLines(clean);
46
+ default:
47
+ return collapseBlankLines(truncateMiddle(clean, MAX_LOG_LINES));
48
+ }
49
+ }
50
+ /**
51
+ * Parse git status output into a compact format.
52
+ * Handles both porcelain and human-readable output.
53
+ */
54
+ function filterStatus(output) {
55
+ const lines = output.split('\n').filter((l) => l.trim().length > 0);
56
+ // Detect porcelain format (lines start with XY + space)
57
+ const porcelainPattern = /^[ MADRCU?!]{2} /;
58
+ const isPorcelain = lines.length > 0 && lines.every((l) => porcelainPattern.test(l));
59
+ if (isPorcelain) {
60
+ return lines
61
+ .map((line) => {
62
+ const status = line.slice(0, 2).trim();
63
+ const file = line.slice(3);
64
+ return `[${status || '?'}] ${file}`;
65
+ })
66
+ .join('\n');
67
+ }
68
+ // Human-readable format: keep but compress. Remove "On branch" and
69
+ // "Your branch is up to date" boilerplate; keep the file lists.
70
+ const result = lines.filter((l) => !l.startsWith('On branch') &&
71
+ !l.startsWith('Your branch is up to date') &&
72
+ !l.startsWith(' (use "git'));
73
+ return result.length > 0 ? collapseBlankLines(result.join('\n')) : 'clean';
74
+ }
75
+ /**
76
+ * Compress git log to one-line-per-commit format, capped at MAX_LOG_LINES.
77
+ */
78
+ function filterLog(output) {
79
+ // If already one-line format (--oneline), just truncate
80
+ const lines = output.split('\n');
81
+ const isOneline = lines.every((l) => !l.startsWith('commit ') && !l.startsWith('Author:'));
82
+ if (isOneline) {
83
+ return truncateMiddle(output, MAX_LOG_LINES);
84
+ }
85
+ // Full log format: extract hash + subject from each commit block
86
+ const commits = [];
87
+ let currentHash = '';
88
+ for (const line of lines) {
89
+ const commitMatch = line.match(/^commit ([a-f0-9]{7,40})/);
90
+ if (commitMatch) {
91
+ currentHash = commitMatch[1].slice(0, 7);
92
+ continue;
93
+ }
94
+ if (line.startsWith(' ') && currentHash) {
95
+ commits.push(`${currentHash} ${line.trim()}`);
96
+ currentHash = '';
97
+ }
98
+ }
99
+ return commits.length > 0
100
+ ? truncateMiddle(commits.join('\n'), MAX_LOG_LINES)
101
+ : truncateMiddle(output, MAX_LOG_LINES);
102
+ }
103
+ /**
104
+ * Compact git diff by removing context lines (unchanged lines starting
105
+ * with space in unified format) and capping total length.
106
+ */
107
+ function filterDiff(output) {
108
+ const lines = output.split('\n');
109
+ const result = [];
110
+ let inHunk = false;
111
+ for (const line of lines) {
112
+ // Keep diff/file headers
113
+ if (line.startsWith('diff --git') ||
114
+ line.startsWith('---') ||
115
+ line.startsWith('+++') ||
116
+ line.startsWith('@@')) {
117
+ result.push(line);
118
+ inHunk = line.startsWith('@@');
119
+ continue;
120
+ }
121
+ // Inside a hunk: keep only changed lines (+ and -)
122
+ if (inHunk) {
123
+ if (line.startsWith('+') || line.startsWith('-')) {
124
+ result.push(line);
125
+ }
126
+ // Skip context lines (start with space)
127
+ continue;
128
+ }
129
+ // Outside hunks: keep (e.g., binary file notices, mode changes)
130
+ result.push(line);
131
+ }
132
+ return truncateMiddle(result.join('\n'), MAX_DIFF_LINES);
133
+ }
134
+ /**
135
+ * Filter git show — use --stat format when possible, otherwise
136
+ * treat as diff.
137
+ */
138
+ function filterShow(output) {
139
+ // If output looks like a stat summary (has " | " column), keep as-is
140
+ if (output.includes(' | ')) {
141
+ return truncateMiddle(output, MAX_LOG_LINES);
142
+ }
143
+ // Otherwise treat as a diff
144
+ return filterDiff(output);
145
+ }
146
+ /** Extract the commit hash from git commit output. */
147
+ function filterCommit(output) {
148
+ const match = output.match(/\[[\w/.-]+ ([a-f0-9]{7,})\]/);
149
+ return match ? `ok ${match[1]}` : 'ok';
150
+ }
151
+ /** Extract branch/remote info from git push output. */
152
+ function filterPush(output) {
153
+ const branchMatch = output.match(/(\S+)\s*->\s*(\S+)/);
154
+ if (branchMatch)
155
+ return `ok ${branchMatch[1]} → ${branchMatch[2]}`;
156
+ // "Everything up-to-date" case
157
+ if (output.toLowerCase().includes('up-to-date') || output.toLowerCase().includes('up to date')) {
158
+ return 'ok (up-to-date)';
159
+ }
160
+ return 'ok';
161
+ }
162
+ /** Extract stats from git pull output. */
163
+ function filterPull(output) {
164
+ if (output.includes('Already up to date'))
165
+ return 'ok (up-to-date)';
166
+ const statsMatch = output.match(/(\d+) files? changed(?:, (\d+) insertions?\(\+\))?(?:, (\d+) deletions?\(-\))?/);
167
+ if (statsMatch) {
168
+ const files = statsMatch[1];
169
+ const ins = statsMatch[2] ?? '0';
170
+ const del = statsMatch[3] ?? '0';
171
+ return `ok ${files} files +${ins} -${del}`;
172
+ }
173
+ return 'ok';
174
+ }
175
+ /** Filter git branch — just the branch names, no decoration noise. */
176
+ function filterBranch(output) {
177
+ return output
178
+ .split('\n')
179
+ .map((l) => l.replace(/^\*?\s+/, '').trim())
180
+ .filter((l) => l.length > 0)
181
+ .join('\n');
182
+ }
183
+ /** Simple "ok" filter for commands whose output we mostly don't need. */
184
+ function filterSimpleOk(output, label) {
185
+ if (output.toLowerCase().includes('error') || output.toLowerCase().includes('fatal')) {
186
+ return output;
187
+ }
188
+ return `ok (${label})`;
189
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * npm/pnpm/yarn output filter — strips boilerplate from package
3
+ * manager commands, keeping errors and actionable output.
4
+ *
5
+ * Covers: install, test, run (build/lint/etc.), list/ls.
6
+ * Unrecognized subcommands fall through to basic cleanup.
7
+ */
8
+ /**
9
+ * Filter npm/pnpm/yarn output. The `manager` param is the binary name
10
+ * ("npm", "pnpm", or "yarn") — filtering logic is the same for all.
11
+ */
12
+ export declare function filterNpm(subcommand: string, output: string): string;
13
+ //# sourceMappingURL=npm-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm-filter.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/src/infrastructure/services/subprocess-filter/filters/npm-filter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH;;;GAGG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CA2BpE"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * npm/pnpm/yarn output filter — strips boilerplate from package
3
+ * manager commands, keeping errors and actionable output.
4
+ *
5
+ * Covers: install, test, run (build/lint/etc.), list/ls.
6
+ * Unrecognized subcommands fall through to basic cleanup.
7
+ */
8
+ import { stripAnsi, collapseBlankLines, deduplicateLines, truncateMiddle, } from './shared-helpers.js';
9
+ const MAX_LINES = 80;
10
+ /**
11
+ * Filter npm/pnpm/yarn output. The `manager` param is the binary name
12
+ * ("npm", "pnpm", or "yarn") — filtering logic is the same for all.
13
+ */
14
+ export function filterNpm(subcommand, output) {
15
+ const clean = stripAnsi(output).trim();
16
+ if (clean.length === 0)
17
+ return 'ok';
18
+ // Preserve error output unfiltered
19
+ if (hasErrors(clean)) {
20
+ return collapseBlankLines(truncateMiddle(clean, MAX_LINES));
21
+ }
22
+ switch (subcommand) {
23
+ case 'install':
24
+ case 'i':
25
+ case 'ci':
26
+ case 'add':
27
+ return filterInstall(clean);
28
+ case 'test':
29
+ case 'run':
30
+ case 'exec':
31
+ return filterRun(clean);
32
+ case 'list':
33
+ case 'ls':
34
+ return filterList(clean);
35
+ case 'outdated':
36
+ return filterOutdated(clean);
37
+ default:
38
+ return collapseBlankLines(truncateMiddle(clean, MAX_LINES));
39
+ }
40
+ }
41
+ /** Check for error indicators that mean we should preserve full output. */
42
+ function hasErrors(output) {
43
+ const lower = output.toLowerCase();
44
+ return (lower.includes('err!') ||
45
+ lower.includes('error') ||
46
+ lower.includes('enoent') ||
47
+ lower.includes('eacces') ||
48
+ lower.includes('npm warn') ||
49
+ lower.includes('failed'));
50
+ }
51
+ /**
52
+ * Filter install output — strip download/resolution progress, keep
53
+ * the final summary.
54
+ */
55
+ function filterInstall(output) {
56
+ const lines = output.split('\n');
57
+ const result = lines.filter((l) => !l.startsWith('npm warn deprecated') &&
58
+ !l.match(/^\s*$/) &&
59
+ !l.includes('packages in') &&
60
+ !l.includes('added ') &&
61
+ !l.includes('removed ') &&
62
+ !l.includes('up to date') &&
63
+ !l.includes('reused ') &&
64
+ !l.includes('Resolving') &&
65
+ !l.includes('Downloading') &&
66
+ !l.includes('looking for funding'));
67
+ if (result.length === 0)
68
+ return 'ok (installed)';
69
+ return truncateMiddle(result.join('\n'), MAX_LINES);
70
+ }
71
+ /**
72
+ * Filter test/run output — strip lifecycle boilerplate, keep test
73
+ * results and errors.
74
+ */
75
+ function filterRun(output) {
76
+ const lines = output.split('\n');
77
+ const result = lines.filter((l) => !l.match(/^> [\w@/.-]+ /) && // Strip "> project@1.0.0 test" prefix
78
+ !l.match(/^\s*$/));
79
+ const filtered = deduplicateLines(result.join('\n'));
80
+ return collapseBlankLines(truncateMiddle(filtered, MAX_LINES));
81
+ }
82
+ /**
83
+ * Filter list output — truncate to top-level deps only.
84
+ */
85
+ function filterList(output) {
86
+ const lines = output.split('\n');
87
+ // Keep only depth-0 lines (no leading whitespace beyond the tree markers)
88
+ const topLevel = lines.filter((l) => !l.startsWith(' ') || l.startsWith('├─') || l.startsWith('└─'));
89
+ return truncateMiddle(topLevel.join('\n'), MAX_LINES);
90
+ }
91
+ /**
92
+ * Filter outdated — keep the table but truncate.
93
+ */
94
+ function filterOutdated(output) {
95
+ return truncateMiddle(output, MAX_LINES);
96
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Shared helpers used across all subprocess output filters.
3
+ *
4
+ * These are small, pure functions for text transformation —
5
+ * deduplication, blank-line collapsing, ANSI stripping, and
6
+ * middle-truncation. Each filter composes from these primitives.
7
+ */
8
+ export declare function stripAnsi(text: string): string;
9
+ /**
10
+ * Collapse runs of 3+ consecutive blank lines into a single blank line.
11
+ * Trims trailing whitespace from each line as a side effect.
12
+ */
13
+ export declare function collapseBlankLines(text: string): string;
14
+ /**
15
+ * Deduplicate consecutive identical lines, appending a count.
16
+ *
17
+ * Example:
18
+ * "ok\nok\nok\nfail" → "ok (×3)\nfail"
19
+ */
20
+ export declare function deduplicateLines(text: string): string;
21
+ /**
22
+ * Truncate text that exceeds maxLines by keeping the top half and
23
+ * bottom quarter, inserting an omission marker in the middle.
24
+ *
25
+ * Preserves the head (most likely context/setup) and tail (most
26
+ * likely summary/errors) which are the parts LLMs benefit from most.
27
+ */
28
+ export declare function truncateMiddle(text: string, maxLines: number): string;
29
+ //# sourceMappingURL=shared-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-helpers.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/src/infrastructure/services/subprocess-filter/filters/shared-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmBvD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBrD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAarE"}