@posthog/agent 1.11.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/README.md +26 -65
  2. package/dist/_virtual/_commonjsHelpers.js +6 -0
  3. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  4. package/dist/_virtual/index.js +4 -0
  5. package/dist/_virtual/index.js.map +1 -0
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/node_modules/@ai-sdk/anthropic/dist/index.js +1154 -0
  9. package/dist/node_modules/@ai-sdk/anthropic/dist/index.js.map +1 -0
  10. package/dist/node_modules/@ai-sdk/provider/dist/index.js +296 -0
  11. package/dist/node_modules/@ai-sdk/provider/dist/index.js.map +1 -0
  12. package/dist/node_modules/@ai-sdk/provider-utils/dist/index.js +576 -0
  13. package/dist/node_modules/@ai-sdk/provider-utils/dist/index.js.map +1 -0
  14. package/dist/node_modules/@ai-sdk/ui-utils/dist/index.js +741 -0
  15. package/dist/node_modules/@ai-sdk/ui-utils/dist/index.js.map +1 -0
  16. package/dist/node_modules/@opentelemetry/api/build/esm/api/context.js +112 -0
  17. package/dist/node_modules/@opentelemetry/api/build/esm/api/context.js.map +1 -0
  18. package/dist/node_modules/@opentelemetry/api/build/esm/api/diag.js +123 -0
  19. package/dist/node_modules/@opentelemetry/api/build/esm/api/diag.js.map +1 -0
  20. package/dist/node_modules/@opentelemetry/api/build/esm/api/metrics.js +62 -0
  21. package/dist/node_modules/@opentelemetry/api/build/esm/api/metrics.js.map +1 -0
  22. package/dist/node_modules/@opentelemetry/api/build/esm/api/propagation.js +91 -0
  23. package/dist/node_modules/@opentelemetry/api/build/esm/api/propagation.js.map +1 -0
  24. package/dist/node_modules/@opentelemetry/api/build/esm/api/trace.js +79 -0
  25. package/dist/node_modules/@opentelemetry/api/build/esm/api/trace.js.map +1 -0
  26. package/dist/node_modules/@opentelemetry/api/build/esm/baggage/context-helpers.js +59 -0
  27. package/dist/node_modules/@opentelemetry/api/build/esm/baggage/context-helpers.js.map +1 -0
  28. package/dist/node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js +99 -0
  29. package/dist/node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js.map +1 -0
  30. package/dist/node_modules/@opentelemetry/api/build/esm/baggage/utils.js +31 -0
  31. package/dist/node_modules/@opentelemetry/api/build/esm/baggage/utils.js.map +1 -0
  32. package/dist/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js +69 -0
  33. package/dist/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js.map +1 -0
  34. package/dist/node_modules/@opentelemetry/api/build/esm/context/context.js +54 -0
  35. package/dist/node_modules/@opentelemetry/api/build/esm/context/context.js.map +1 -0
  36. package/dist/node_modules/@opentelemetry/api/build/esm/context-api.js +22 -0
  37. package/dist/node_modules/@opentelemetry/api/build/esm/context-api.js.map +1 -0
  38. package/dist/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js +104 -0
  39. package/dist/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js.map +1 -0
  40. package/dist/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js +44 -0
  41. package/dist/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js.map +1 -0
  42. package/dist/node_modules/@opentelemetry/api/build/esm/diag/types.js +43 -0
  43. package/dist/node_modules/@opentelemetry/api/build/esm/diag/types.js.map +1 -0
  44. package/dist/node_modules/@opentelemetry/api/build/esm/diag-api.js +27 -0
  45. package/dist/node_modules/@opentelemetry/api/build/esm/diag-api.js.map +1 -0
  46. package/dist/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js +62 -0
  47. package/dist/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js.map +1 -0
  48. package/dist/node_modules/@opentelemetry/api/build/esm/internal/semver.js +121 -0
  49. package/dist/node_modules/@opentelemetry/api/build/esm/internal/semver.js.map +1 -0
  50. package/dist/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js +167 -0
  51. package/dist/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js.map +1 -0
  52. package/dist/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeterProvider.js +33 -0
  53. package/dist/node_modules/@opentelemetry/api/build/esm/metrics/NoopMeterProvider.js.map +1 -0
  54. package/dist/node_modules/@opentelemetry/api/build/esm/metrics-api.js +22 -0
  55. package/dist/node_modules/@opentelemetry/api/build/esm/metrics-api.js.map +1 -0
  56. package/dist/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js +21 -0
  57. package/dist/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js.map +1 -0
  58. package/dist/node_modules/@opentelemetry/api/build/esm/propagation/NoopTextMapPropagator.js +35 -0
  59. package/dist/node_modules/@opentelemetry/api/build/esm/propagation/NoopTextMapPropagator.js.map +1 -0
  60. package/dist/node_modules/@opentelemetry/api/build/esm/propagation/TextMapPropagator.js +40 -0
  61. package/dist/node_modules/@opentelemetry/api/build/esm/propagation/TextMapPropagator.js.map +1 -0
  62. package/dist/node_modules/@opentelemetry/api/build/esm/propagation-api.js +22 -0
  63. package/dist/node_modules/@opentelemetry/api/build/esm/propagation-api.js.map +1 -0
  64. package/dist/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js +70 -0
  65. package/dist/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js.map +1 -0
  66. package/dist/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js +78 -0
  67. package/dist/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js.map +1 -0
  68. package/dist/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js +34 -0
  69. package/dist/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js.map +1 -0
  70. package/dist/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js +55 -0
  71. package/dist/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js.map +1 -0
  72. package/dist/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js +56 -0
  73. package/dist/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js.map +1 -0
  74. package/dist/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js +76 -0
  75. package/dist/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js.map +1 -0
  76. package/dist/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js +27 -0
  77. package/dist/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js.map +1 -0
  78. package/dist/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js +45 -0
  79. package/dist/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js.map +1 -0
  80. package/dist/node_modules/@opentelemetry/api/build/esm/trace/status.js +22 -0
  81. package/dist/node_modules/@opentelemetry/api/build/esm/trace/status.js.map +1 -0
  82. package/dist/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js +25 -0
  83. package/dist/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js.map +1 -0
  84. package/dist/node_modules/@opentelemetry/api/build/esm/trace-api.js +24 -0
  85. package/dist/node_modules/@opentelemetry/api/build/esm/trace-api.js.map +1 -0
  86. package/dist/node_modules/@opentelemetry/api/build/esm/version.js +20 -0
  87. package/dist/node_modules/@opentelemetry/api/build/esm/version.js.map +1 -0
  88. package/dist/node_modules/ai/dist/index.js +2870 -0
  89. package/dist/node_modules/ai/dist/index.js.map +1 -0
  90. package/dist/node_modules/nanoid/non-secure/index.js +13 -0
  91. package/dist/node_modules/nanoid/non-secure/index.js.map +1 -0
  92. package/dist/node_modules/secure-json-parse/index.js +133 -0
  93. package/dist/node_modules/secure-json-parse/index.js.map +1 -0
  94. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js +37 -0
  95. package/dist/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -0
  96. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js +26 -0
  97. package/dist/node_modules/zod-to-json-schema/dist/esm/Refs.js.map +1 -0
  98. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +17 -0
  99. package/dist/node_modules/zod-to-json-schema/dist/esm/errorMessages.js.map +1 -0
  100. package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +11 -0
  101. package/dist/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js.map +1 -0
  102. package/dist/node_modules/zod-to-json-schema/dist/esm/index.js +8 -0
  103. package/dist/node_modules/zod-to-json-schema/dist/esm/index.js.map +1 -0
  104. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js +66 -0
  105. package/dist/node_modules/zod-to-json-schema/dist/esm/parseDef.js.map +1 -0
  106. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +21 -0
  107. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/any.js.map +1 -0
  108. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +30 -0
  109. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/array.js.map +1 -0
  110. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +53 -0
  111. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js.map +1 -0
  112. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +8 -0
  113. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js.map +1 -0
  114. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +8 -0
  115. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js.map +1 -0
  116. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +8 -0
  117. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js.map +1 -0
  118. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +50 -0
  119. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/date.js.map +1 -0
  120. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +11 -0
  121. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/default.js.map +1 -0
  122. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +11 -0
  123. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js.map +1 -0
  124. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +9 -0
  125. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js.map +1 -0
  126. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +56 -0
  127. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js.map +1 -0
  128. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +24 -0
  129. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js.map +1 -0
  130. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +30 -0
  131. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/map.js.map +1 -0
  132. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +19 -0
  133. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js.map +1 -0
  134. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +15 -0
  135. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/never.js.map +1 -0
  136. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +13 -0
  137. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/null.js.map +1 -0
  138. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +37 -0
  139. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js.map +1 -0
  140. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +56 -0
  141. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/number.js.map +1 -0
  142. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +76 -0
  143. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/object.js.map +1 -0
  144. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +25 -0
  145. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js.map +1 -0
  146. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +24 -0
  147. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js.map +1 -0
  148. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +8 -0
  149. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js.map +1 -0
  150. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +8 -0
  151. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js.map +1 -0
  152. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +65 -0
  153. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/record.js.map +1 -0
  154. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +24 -0
  155. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/set.js.map +1 -0
  156. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +350 -0
  157. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/string.js.map +1 -0
  158. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +36 -0
  159. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js.map +1 -0
  160. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +10 -0
  161. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js.map +1 -0
  162. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +84 -0
  163. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/union.js.map +1 -0
  164. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +8 -0
  165. package/dist/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js.map +1 -0
  166. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js +110 -0
  167. package/dist/node_modules/zod-to-json-schema/dist/esm/selectParser.js.map +1 -0
  168. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +90 -0
  169. package/dist/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js.map +1 -0
  170. package/dist/src/adapters/types.d.ts +1 -1
  171. package/dist/src/agent.d.ts +3 -13
  172. package/dist/src/agent.d.ts.map +1 -1
  173. package/dist/src/agent.js +94 -504
  174. package/dist/src/agent.js.map +1 -1
  175. package/dist/src/agents/execution.d.ts +1 -1
  176. package/dist/src/agents/execution.js +2 -2
  177. package/dist/src/agents/execution.js.map +1 -1
  178. package/dist/src/agents/planning.d.ts +1 -1
  179. package/dist/src/agents/planning.d.ts.map +1 -1
  180. package/dist/src/agents/planning.js +1 -2
  181. package/dist/src/agents/planning.js.map +1 -1
  182. package/dist/src/agents/research.d.ts +1 -1
  183. package/dist/src/agents/research.d.ts.map +1 -1
  184. package/dist/src/agents/research.js +3 -6
  185. package/dist/src/agents/research.js.map +1 -1
  186. package/dist/src/git-manager.js +1 -1
  187. package/dist/src/git-manager.js.map +1 -1
  188. package/dist/src/posthog-api.d.ts +0 -8
  189. package/dist/src/posthog-api.d.ts.map +1 -1
  190. package/dist/src/posthog-api.js +0 -32
  191. package/dist/src/posthog-api.js.map +1 -1
  192. package/dist/src/prompt-builder.d.ts.map +1 -1
  193. package/dist/src/prompt-builder.js +0 -1
  194. package/dist/src/prompt-builder.js.map +1 -1
  195. package/dist/src/structured-extraction.d.ts +2 -2
  196. package/dist/src/structured-extraction.d.ts.map +1 -1
  197. package/dist/src/structured-extraction.js +51 -110
  198. package/dist/src/structured-extraction.js.map +1 -1
  199. package/dist/src/task-progress-reporter.d.ts +0 -6
  200. package/dist/src/task-progress-reporter.d.ts.map +1 -1
  201. package/dist/src/task-progress-reporter.js +2 -26
  202. package/dist/src/task-progress-reporter.js.map +1 -1
  203. package/dist/src/template-manager.d.ts.map +1 -1
  204. package/dist/src/template-manager.js +26 -4
  205. package/dist/src/template-manager.js.map +1 -1
  206. package/dist/src/types.d.ts +0 -4
  207. package/dist/src/types.d.ts.map +1 -1
  208. package/dist/src/types.js +0 -1
  209. package/dist/src/types.js.map +1 -1
  210. package/dist/src/workflow/config.d.ts +3 -0
  211. package/dist/src/workflow/config.d.ts.map +1 -0
  212. package/dist/src/workflow/config.js +43 -0
  213. package/dist/src/workflow/config.js.map +1 -0
  214. package/dist/src/workflow/steps/build.d.ts +3 -0
  215. package/dist/src/workflow/steps/build.d.ts.map +1 -0
  216. package/dist/src/workflow/steps/build.js +64 -0
  217. package/dist/src/workflow/steps/build.js.map +1 -0
  218. package/dist/src/workflow/steps/plan.d.ts +3 -0
  219. package/dist/src/workflow/steps/plan.d.ts.map +1 -0
  220. package/dist/src/workflow/steps/plan.js +86 -0
  221. package/dist/src/workflow/steps/plan.js.map +1 -0
  222. package/dist/src/workflow/steps/research.d.ts +3 -0
  223. package/dist/src/workflow/steps/research.d.ts.map +1 -0
  224. package/dist/src/workflow/steps/research.js +124 -0
  225. package/dist/src/workflow/steps/research.js.map +1 -0
  226. package/dist/src/workflow/types.d.ts +48 -0
  227. package/dist/src/workflow/types.d.ts.map +1 -0
  228. package/dist/src/workflow/utils.d.ts +12 -0
  229. package/dist/src/workflow/utils.d.ts.map +1 -0
  230. package/dist/src/workflow/utils.js +38 -0
  231. package/dist/src/workflow/utils.js.map +1 -0
  232. package/package.json +6 -4
  233. package/src/adapters/types.ts +1 -1
  234. package/src/agent.ts +114 -554
  235. package/src/agents/execution.ts +2 -2
  236. package/src/agents/planning.ts +1 -2
  237. package/src/agents/research.ts +3 -6
  238. package/src/git-manager.ts +1 -1
  239. package/src/posthog-api.ts +0 -40
  240. package/src/prompt-builder.ts +0 -2
  241. package/src/structured-extraction.ts +58 -115
  242. package/src/task-progress-reporter.ts +2 -34
  243. package/src/template-manager.ts +35 -5
  244. package/src/types.ts +0 -7
  245. package/src/workflow/config.ts +42 -0
  246. package/src/workflow/steps/build.ts +87 -0
  247. package/src/workflow/steps/plan.ts +112 -0
  248. package/src/workflow/steps/research.ts +156 -0
  249. package/src/workflow/types.ts +53 -0
  250. package/src/workflow/utils.ts +50 -0
  251. package/dist/src/agent-registry.d.ts +0 -16
  252. package/dist/src/agent-registry.d.ts.map +0 -1
  253. package/dist/src/agent-registry.js +0 -62
  254. package/dist/src/agent-registry.js.map +0 -1
  255. package/dist/src/stage-executor.d.ts +0 -20
  256. package/dist/src/stage-executor.d.ts.map +0 -1
  257. package/dist/src/stage-executor.js +0 -178
  258. package/dist/src/stage-executor.js.map +0 -1
  259. package/dist/src/workflow-registry.d.ts +0 -11
  260. package/dist/src/workflow-registry.d.ts.map +0 -1
  261. package/dist/src/workflow-registry.js +0 -27
  262. package/dist/src/workflow-registry.js.map +0 -1
  263. package/dist/src/workflow-types.d.ts +0 -45
  264. package/dist/src/workflow-types.d.ts.map +0 -1
  265. package/src/agent-registry.ts +0 -65
  266. package/src/stage-executor.ts +0 -210
  267. package/src/workflow-registry.ts +0 -30
  268. package/src/workflow-types.ts +0 -52
@@ -34,11 +34,11 @@ export const EXECUTION_SYSTEM_PROMPT = `<context>
34
34
  - Verified no build artifacts or dependencies are being committed
35
35
  </checklist>
36
36
 
37
- <workflow>
37
+ <approach>
38
38
  - first make a plan and create a todo list
39
39
  - execute the todo list one by one
40
40
  - test the changes
41
- </workflow>
41
+ </approach>
42
42
 
43
43
  <output_format>
44
44
  Once finished respond with a summary of changes made
@@ -11,6 +11,7 @@ You are a specialized planning agent that analyzes codebases and creates detaile
11
11
  - **Read-Only Mode**: You can only read files, search code, and analyze the codebase
12
12
  - **No Modifications**: You cannot make any changes, edits, or execute commands
13
13
  - **Research Focus**: Your goal is understanding and planning, not implementation
14
+ - **Response Format**: Respond only with the markdown content above, no other text or formatting, no acknowledgement, no explanation, no nothing.
14
15
 
15
16
  ## Available Tools
16
17
 
@@ -49,8 +50,6 @@ When given a task, follow this systematic approach:
49
50
 
50
51
  ## Plan Output
51
52
 
52
- When you have completed your analysis, use the \`exit_plan_mode\` tool to present your plan. Your plan should include:
53
-
54
53
  - **Summary**: Brief overview of the implementation approach
55
54
  - **Files to Create/Modify**: Specific paths and purposes
56
55
  - **Implementation Steps**: Ordered list of actions to take
@@ -18,7 +18,6 @@ You are a research agent that explores codebases to understand implementation co
18
18
  - Code search and analysis
19
19
  - Repository structure analysis
20
20
  - Documentation review
21
- - \`create_plan\` tool for creating your research artifact
22
21
 
23
22
  ## Research Process
24
23
 
@@ -46,8 +45,6 @@ When given a task, follow this systematic approach:
46
45
 
47
46
  ## Output Format
48
47
 
49
- After completing your research, you MUST use the \`create_plan\` tool to create a research.md artifact with your questions.
50
-
51
48
  The artifact MUST follow this EXACT markdown format (this is critical for parsing):
52
49
 
53
50
  \`\`\`markdown
@@ -88,16 +85,16 @@ Based on my analysis of the codebase, here are the key questions to guide implem
88
85
 
89
86
  ## Important Requirements
90
87
 
91
- - Generate 2-5 questions (no more, no less)
88
+ - DO NOT GENERATE ANY QUESTIONS IF YOU DON'T HAVE ANY (instead say "No questions required")
89
+ - Generate up to 5 questions (no more)
92
90
  - Make options specific and reference actual code/patterns you find
93
91
  - Each question must have at least 2 concrete options plus "Something else"
94
92
  - Focus on architectural and implementation approach decisions
95
93
  - Reference specific files, components, or patterns in your options
96
94
  - Make sure the questions help guide a clear implementation path
95
+ - Respond only with the markdown content above, no other text or formatting, no acknowledgement, no explanation, no nothing.
97
96
 
98
97
  ## Final Step
99
98
 
100
- Once you have completed your research and identified the questions, use the \`create_plan\` tool to create the research.md artifact with the markdown content above. Do NOT use any other tools after creating the artifact.
101
-
102
99
  Your research should be thorough enough that the questions help clarify the user's preferences and guide the planning phase effectively.`;
103
100
 
@@ -161,7 +161,7 @@ export class GitManager {
161
161
  await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);
162
162
  }
163
163
 
164
- // Utility methods for PostHog task workflow
164
+ // Utility methods for PostHog task execution
165
165
  async createTaskPlanningBranch(taskId: string, baseBranch?: string): Promise<string> {
166
166
  let branchName = `posthog/task-${taskId}-planning`;
167
167
  let counter = 1;
@@ -1,5 +1,4 @@
1
1
  import type { Task, TaskRun, LogEntry, SupportingFile, PostHogAPIConfig, PostHogResource, ResourceType, UrlMention } from './types.js';
2
- import type { WorkflowDefinition, AgentDefinition } from './workflow-types.js';
3
2
 
4
3
  interface PostHogApiResponse<T> {
5
4
  results?: T[];
@@ -107,8 +106,6 @@ export class PostHogAPIClient {
107
106
  repository?: string;
108
107
  organization?: string;
109
108
  origin_product?: string;
110
- workflow?: string;
111
- current_stage?: string;
112
109
  }): Promise<Task[]> {
113
110
  const teamId = await this.getTeamId();
114
111
  const url = new URL(`${this.baseUrl}/api/projects/${teamId}/tasks/`);
@@ -171,26 +168,6 @@ export class PostHogAPIClient {
171
168
  });
172
169
  }
173
170
 
174
- async updateTaskRunStage(taskId: string, runId: string, stageId: string): Promise<TaskRun> {
175
- const teamId = await this.getTeamId();
176
- return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/update_stage/`, {
177
- method: 'PATCH',
178
- body: JSON.stringify({ current_stage: stageId }),
179
- });
180
- }
181
-
182
- async progressTaskRun(taskId: string, runId: string, nextStageId?: string): Promise<TaskRun> {
183
- const teamId = await this.getTeamId();
184
- const payload: Record<string, string> = {};
185
- if (nextStageId) {
186
- payload.next_stage_id = nextStageId;
187
- }
188
- return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/progress_run/`, {
189
- method: 'POST',
190
- body: JSON.stringify(payload),
191
- });
192
- }
193
-
194
171
  async setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun> {
195
172
  const teamId = await this.getTeamId();
196
173
  return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {
@@ -207,23 +184,6 @@ export class PostHogAPIClient {
207
184
  });
208
185
  }
209
186
 
210
- // Workflow endpoints
211
- async fetchWorkflow(workflowId: string): Promise<WorkflowDefinition> {
212
- const teamId = await this.getTeamId();
213
- return this.apiRequest<WorkflowDefinition>(`/api/projects/${teamId}/workflows/${workflowId}/`);
214
- }
215
-
216
- async listWorkflows(): Promise<WorkflowDefinition[]> {
217
- const teamId = await this.getTeamId();
218
- const response = await this.apiRequest<PostHogApiResponse<WorkflowDefinition>>(`/api/projects/${teamId}/workflows/`);
219
- return response.results || [];
220
- }
221
-
222
- // Agent catalog exposure
223
- async listAgents(): Promise<AgentDefinition[]> {
224
- return this.apiRequest<AgentDefinition[]>(`/api/agents/`);
225
- }
226
-
227
187
  /**
228
188
  * Fetch error details from PostHog error tracking
229
189
  */
@@ -254,8 +254,6 @@ export class PromptBuilder {
254
254
  this.logger.debug('No existing task files found for research', { taskId: task.id });
255
255
  }
256
256
 
257
- prompt += `\n\nPlease explore the codebase thoroughly and generate 3-5 clarifying questions that will help guide the implementation of this task. Use the \`create_plan\` tool to create a research.md artifact with your questions in the markdown format specified in your system prompt.`;
258
-
259
257
  return prompt;
260
258
  }
261
259
 
@@ -1,4 +1,6 @@
1
- import OpenAI from 'openai';
1
+ import { generateObject } from 'ai';
2
+ import { anthropic } from '@ai-sdk/anthropic';
3
+ import { z } from 'zod';
2
4
  import { Logger } from './utils/logger.js';
3
5
 
4
6
  export interface ExtractedQuestion {
@@ -12,73 +14,54 @@ export interface ExtractedQuestionWithAnswer extends ExtractedQuestion {
12
14
  justification: string;
13
15
  }
14
16
 
15
- const questionsOnlySchema = {
16
- type: 'object',
17
- properties: {
18
- questions: {
19
- type: 'array',
20
- items: {
21
- type: 'object',
22
- properties: {
23
- id: { type: 'string' },
24
- question: { type: 'string' },
25
- options: {
26
- type: 'array',
27
- items: { type: 'string' }
28
- }
29
- },
30
- required: ['id', 'question', 'options'],
31
- additionalProperties: false
32
- }
33
- }
34
- },
35
- required: ['questions'],
36
- additionalProperties: false
37
- };
38
-
39
- const questionsWithAnswersSchema = {
40
- type: 'object',
41
- properties: {
42
- questions: {
43
- type: 'array',
44
- items: {
45
- type: 'object',
46
- properties: {
47
- id: { type: 'string' },
48
- question: { type: 'string' },
49
- options: {
50
- type: 'array',
51
- items: { type: 'string' }
52
- },
53
- recommendedAnswer: { type: 'string' },
54
- justification: { type: 'string' }
55
- },
56
- required: ['id', 'question', 'options', 'recommendedAnswer', 'justification'],
57
- additionalProperties: false
58
- }
59
- }
60
- },
61
- required: ['questions'],
62
- additionalProperties: false
63
- };
17
+ const questionsOnlySchema = z.object({
18
+ questions: z.array(
19
+ z.object({
20
+ id: z.string(),
21
+ question: z.string(),
22
+ options: z.array(z.string()),
23
+ })
24
+ ),
25
+ });
26
+
27
+ const questionsWithAnswersSchema = z.object({
28
+ questions: z.array(
29
+ z.object({
30
+ id: z.string(),
31
+ question: z.string(),
32
+ options: z.array(z.string()),
33
+ recommendedAnswer: z.string().describe('The letter of the recommended option (e.g., "a", "b", "c")'),
34
+ justification: z.string().describe('Brief explanation for the recommended answer'),
35
+ })
36
+ ),
37
+ });
64
38
 
65
39
  export interface StructuredExtractor {
66
40
  extractQuestions(researchContent: string): Promise<ExtractedQuestion[]>;
67
41
  extractQuestionsWithAnswers(researchContent: string): Promise<ExtractedQuestionWithAnswer[]>;
68
42
  }
69
43
 
70
- export class OpenAIExtractor implements StructuredExtractor {
71
- private client: OpenAI;
44
+ export class AISDKExtractor implements StructuredExtractor {
72
45
  private logger: Logger;
46
+ private model: any;
73
47
 
74
48
  constructor(logger?: Logger) {
75
- const apiKey = process.env.OPENAI_API_KEY;
49
+ this.logger = logger || new Logger({ debug: false, prefix: '[AISDKExtractor]' });
50
+
51
+ // Determine which provider to use based on environment variables
52
+ // Priority: Anthropic (if ANTHROPIC_BASE_URL is set) > OpenAI
53
+ const apiKey = process.env.ANTHROPIC_AUTH_TOKEN
54
+ || process.env.ANTHROPIC_API_KEY
55
+ || process.env.OPENAI_API_KEY;
56
+
76
57
  if (!apiKey) {
77
- throw new Error('OPENAI_API_KEY environment variable is required for structured extraction');
58
+ throw new Error('Missing API key for structured extraction. Ensure the LLM gateway is configured.');
78
59
  }
79
-
80
- this.client = new OpenAI({ apiKey });
81
- this.logger = logger || new Logger({ debug: false, prefix: '[OpenAIExtractor]' });
60
+
61
+ const baseURL = process.env.ANTHROPIC_BASE_URL || process.env.OPENAI_BASE_URL;
62
+ const modelName = 'claude-haiku-4-5';
63
+ this.model = anthropic(modelName);
64
+ this.logger.debug('Using Anthropic provider for structured extraction', { modelName, baseURL });
82
65
  }
83
66
 
84
67
  async extractQuestions(researchContent: string): Promise<ExtractedQuestion[]> {
@@ -86,40 +69,20 @@ export class OpenAIExtractor implements StructuredExtractor {
86
69
  contentLength: researchContent.length,
87
70
  });
88
71
 
89
- const completion = await this.client.chat.completions.create({
90
- model: 'gpt-4o-mini',
91
- messages: [
92
- {
93
- role: 'system',
94
- content: 'Extract the research questions from the provided markdown. Return a JSON object matching the schema.',
95
- },
96
- {
97
- role: 'user',
98
- content: researchContent,
99
- },
100
- ],
101
- response_format: {
102
- type: 'json_schema',
103
- json_schema: {
104
- name: 'questions',
105
- strict: true,
106
- schema: questionsOnlySchema,
107
- },
108
- },
72
+ const { object } = await generateObject({
73
+ model: this.model,
74
+ schema: questionsOnlySchema,
75
+ schemaName: 'ResearchQuestions',
76
+ schemaDescription: 'Research questions extracted from markdown content',
77
+ system: 'Extract the research questions from the provided markdown. Return a JSON object matching the schema.',
78
+ prompt: researchContent,
109
79
  });
110
80
 
111
- const content = completion.choices[0].message.content;
112
- if (!content) {
113
- throw new Error('No content in OpenAI response');
114
- }
115
-
116
- const parsed = JSON.parse(content) as { questions: ExtractedQuestion[] };
117
-
118
81
  this.logger.info('Successfully extracted questions', {
119
- questionCount: parsed.questions.length,
82
+ questionCount: object.questions.length,
120
83
  });
121
84
 
122
- return parsed.questions;
85
+ return object.questions;
123
86
  }
124
87
 
125
88
  async extractQuestionsWithAnswers(
@@ -129,39 +92,19 @@ export class OpenAIExtractor implements StructuredExtractor {
129
92
  contentLength: researchContent.length,
130
93
  });
131
94
 
132
- const completion = await this.client.chat.completions.create({
133
- model: 'gpt-4o-mini',
134
- messages: [
135
- {
136
- role: 'system',
137
- content: 'Extract the research questions from the markdown and provide recommended answers based on the analysis. For each question, include a recommendedAnswer (the letter: a, b, c, etc.) and a brief justification. Return a JSON object matching the schema.',
138
- },
139
- {
140
- role: 'user',
141
- content: researchContent,
142
- },
143
- ],
144
- response_format: {
145
- type: 'json_schema',
146
- json_schema: {
147
- name: 'questions_with_answers',
148
- strict: true,
149
- schema: questionsWithAnswersSchema,
150
- },
151
- },
95
+ const { object } = await generateObject({
96
+ model: this.model,
97
+ schema: questionsWithAnswersSchema,
98
+ schemaName: 'ResearchQuestionsWithAnswers',
99
+ schemaDescription: 'Research questions with recommended answers extracted from markdown',
100
+ system: 'Extract the research questions from the markdown and provide recommended answers based on the analysis. For each question, include a recommendedAnswer (the letter: a, b, c, etc.) and a brief justification. Return a JSON object matching the schema.',
101
+ prompt: researchContent,
152
102
  });
153
103
 
154
- const content = completion.choices[0].message.content;
155
- if (!content) {
156
- throw new Error('No content in OpenAI response');
157
- }
158
-
159
- const parsed = JSON.parse(content) as { questions: ExtractedQuestionWithAnswer[] };
160
-
161
104
  this.logger.info('Successfully extracted questions with answers', {
162
- questionCount: parsed.questions.length,
105
+ questionCount: object.questions.length,
163
106
  });
164
107
 
165
- return parsed.questions;
108
+ return object.questions;
166
109
  }
167
110
  }
@@ -51,45 +51,13 @@ export class TaskProgressReporter {
51
51
  }
52
52
  }
53
53
 
54
- async stageStarted(stageKey: string, stageIndex: number): Promise<void> {
55
- await this.update({
56
- status: 'in_progress',
57
- }, `Stage started: ${stageKey}`);
58
- }
59
-
60
- async stageCompleted(stageKey: string, completedStages: number): Promise<void> {
61
- await this.update({
62
- status: 'in_progress',
63
- }, `Stage completed: ${stageKey}`);
64
- }
65
-
66
- async branchCreated(stageKey: string, branchName: string): Promise<void> {
67
- await this.appendLog(`Branch created (${stageKey}): ${branchName}`);
68
- }
69
-
70
- async commitMade(stageKey: string, kind: 'plan' | 'implementation'): Promise<void> {
71
- await this.appendLog(`Commit made (${stageKey}, ${kind})`);
72
- }
73
-
74
- async pullRequestCreated(stageKey: string, prUrl: string): Promise<void> {
75
- await this.appendLog(`Pull request created (${stageKey}): ${prUrl}`);
76
- }
77
-
78
- async noNextStage(stageKey?: string): Promise<void> {
79
- await this.appendLog(
80
- stageKey
81
- ? `No next stage available after '${stageKey}'. Execution halted.`
82
- : 'No next stage available. Execution halted.'
83
- );
84
- }
85
-
86
54
  async complete(): Promise<void> {
87
- await this.update({ status: 'completed' }, 'Workflow execution completed');
55
+ await this.update({ status: 'completed' }, 'Task execution completed');
88
56
  }
89
57
 
90
58
  async fail(error: Error | string): Promise<void> {
91
59
  const message = typeof error === 'string' ? error : error.message;
92
- await this.update({ status: 'failed', error_message: message }, `Workflow execution failed: ${message}`);
60
+ await this.update({ status: 'failed', error_message: message }, `Task execution failed: ${message}`);
93
61
  }
94
62
 
95
63
  async appendLog(line: string): Promise<void> {
@@ -17,14 +17,45 @@ export class TemplateManager {
17
17
  constructor() {
18
18
  const __filename = fileURLToPath(import.meta.url);
19
19
  const __dirname = dirname(__filename);
20
+
21
+ // Exhaustive list of possible template locations
20
22
  const candidateDirs = [
21
- join(__dirname, 'templates'),
23
+ // Standard build output (dist/src/template-manager.js -> dist/templates)
22
24
  join(__dirname, '..', 'templates'),
25
+
26
+ // If preserveModules creates nested structure (dist/src/template-manager.js -> dist/src/templates)
27
+ join(__dirname, 'templates'),
28
+
29
+ // Development scenarios (src/template-manager.ts -> src/templates)
30
+ join(__dirname, '..', '..', 'src', 'templates'),
31
+
32
+ // Package root templates directory
23
33
  join(__dirname, '..', '..', 'templates'),
24
- join(__dirname, '..', '..', 'src', 'templates')
34
+
35
+ // When node_modules symlink or installed (node_modules/@posthog/agent/dist/src/... -> node_modules/@posthog/agent/dist/templates)
36
+ join(__dirname, '..', '..', 'dist', 'templates'),
37
+
38
+ // When consumed from node_modules deep in tree
39
+ join(__dirname, '..', '..', '..', 'templates'),
40
+ join(__dirname, '..', '..', '..', 'dist', 'templates'),
41
+ join(__dirname, '..', '..', '..', 'src', 'templates'),
42
+
43
+ // When bundled by Vite/Webpack (e.g., .vite/build/index.js -> node_modules/@posthog/agent/dist/templates)
44
+ // Try to find node_modules from current location
45
+ join(__dirname, '..', 'node_modules', '@posthog', 'agent', 'dist', 'templates'),
46
+ join(__dirname, '..', '..', 'node_modules', '@posthog', 'agent', 'dist', 'templates'),
47
+ join(__dirname, '..', '..', '..', 'node_modules', '@posthog', 'agent', 'dist', 'templates'),
25
48
  ];
26
49
 
27
50
  const resolvedDir = candidateDirs.find((dir) => existsSync(dir));
51
+
52
+ if (!resolvedDir) {
53
+ console.error('[TemplateManager] Could not find templates directory.');
54
+ console.error('[TemplateManager] Current file:', __filename);
55
+ console.error('[TemplateManager] Current dir:', __dirname);
56
+ console.error('[TemplateManager] Tried:', candidateDirs.map(d => `\n - ${d} (exists: ${existsSync(d)})`).join(''));
57
+ }
58
+
28
59
  this.templatesDir = resolvedDir ?? candidateDirs[0];
29
60
  }
30
61
 
@@ -33,7 +64,7 @@ export class TemplateManager {
33
64
  const templatePath = join(this.templatesDir, templateName);
34
65
  return await fs.readFile(templatePath, 'utf8');
35
66
  } catch (error) {
36
- throw new Error(`Failed to load template ${templateName}: ${error}`);
67
+ throw new Error(`Failed to load template ${templateName} from ${this.templatesDir}: ${error}`);
37
68
  }
38
69
  }
39
70
 
@@ -60,7 +91,6 @@ export class TemplateManager {
60
91
  });
61
92
  }
62
93
 
63
-
64
94
  async generateCustomFile(templateName: string, variables: TemplateVariables): Promise<string> {
65
95
  const template = await this.loadTemplate(templateName);
66
96
  return this.substituteVariables(template, {
@@ -147,7 +177,7 @@ These files are:
147
177
  Customize \`.posthog/.gitignore\` to control which files are committed:
148
178
  - Include plans and documentation by default
149
179
  - Exclude temporary files and sensitive data
150
- - Customize based on your team's workflow
180
+ - Customize based on your team's needs
151
181
 
152
182
  ---
153
183
 
package/src/types.ts CHANGED
@@ -5,7 +5,6 @@ export interface Task {
5
5
  description: string;
6
6
  origin_product: 'error_tracking' | 'eval_clusters' | 'user_created' | 'support_queue' | 'session_summaries';
7
7
  position?: number;
8
- workflow?: string | null;
9
8
  github_integration?: number | null;
10
9
  repository_config?: unknown; // JSONField
11
10
  repository_list: string;
@@ -34,7 +33,6 @@ export interface TaskRun {
34
33
  task: string; // Task ID
35
34
  team: number;
36
35
  branch: string | null;
37
- current_stage: string | null; // WorkflowStage ID
38
36
  status: 'started' | 'in_progress' | 'completed' | 'failed';
39
37
  log: LogEntry[]; // Array of log entry objects
40
38
  error_message: string | null;
@@ -52,8 +50,6 @@ export interface SupportingFile {
52
50
  created_at: string;
53
51
  }
54
52
 
55
- // Removed legacy ExecutionMode in favor of configurable workflows
56
-
57
53
  export enum PermissionMode {
58
54
  PLAN = "plan",
59
55
  DEFAULT = "default",
@@ -155,11 +151,9 @@ export interface StatusEvent extends BaseEvent {
155
151
  type: 'status';
156
152
  phase: string;
157
153
  // Common optional fields (varies by phase):
158
- stage?: string; // Workflow stage (plan, code, complete)
159
154
  kind?: string; // Kind of status (plan, implementation)
160
155
  branch?: string; // Git branch name
161
156
  prUrl?: string; // Pull request URL
162
- workflowId?: string; // Workflow identifier
163
157
  taskId?: string; // Task identifier
164
158
  messageId?: string; // Claude message ID
165
159
  model?: string; // Model name
@@ -271,7 +265,6 @@ export interface TaskExecutionResult {
271
265
  task: Task;
272
266
  plan?: string;
273
267
  executionResult?: ExecutionResult;
274
- // Deprecated: mode removed in workflow-based execution
275
268
  }
276
269
 
277
270
  // MCP Server configuration types (re-exported from Claude SDK for convenience)
@@ -0,0 +1,42 @@
1
+ import type { WorkflowDefinition } from './types.js';
2
+ import { researchStep } from './steps/research.js';
3
+ import { planStep } from './steps/plan.js';
4
+ import { buildStep } from './steps/build.js';
5
+
6
+ const MODELS = {
7
+ SONNET: "claude-sonnet-4-5",
8
+ HAIKU: "claude-haiku-4-5",
9
+ }
10
+
11
+ export const TASK_WORKFLOW: WorkflowDefinition = [
12
+ {
13
+ id: 'research',
14
+ name: 'Research',
15
+ agent: 'research',
16
+ model: MODELS.HAIKU,
17
+ permissionMode: 'plan',
18
+ commit: true,
19
+ push: true,
20
+ run: researchStep,
21
+ },
22
+ {
23
+ id: 'plan',
24
+ name: 'Plan',
25
+ agent: 'planning',
26
+ model: MODELS.SONNET,
27
+ permissionMode: 'plan',
28
+ commit: true,
29
+ push: true,
30
+ run: planStep,
31
+ },
32
+ {
33
+ id: 'build',
34
+ name: 'Build',
35
+ agent: 'execution',
36
+ model: MODELS.SONNET,
37
+ permissionMode: 'acceptEdits',
38
+ commit: true,
39
+ push: true,
40
+ run: buildStep,
41
+ },
42
+ ];
@@ -0,0 +1,87 @@
1
+ import { query } from '@anthropic-ai/claude-agent-sdk';
2
+ import { EXECUTION_SYSTEM_PROMPT } from '../../agents/execution.js';
3
+ import { PermissionMode } from '../../types.js';
4
+ import type { WorkflowStepRunner } from '../types.js';
5
+ import { finalizeStepGitActions } from '../utils.js';
6
+
7
+ export const buildStep: WorkflowStepRunner = async ({ step, context }) => {
8
+ const {
9
+ task,
10
+ cwd,
11
+ options,
12
+ logger,
13
+ promptBuilder,
14
+ adapter,
15
+ mcpServers,
16
+ gitManager,
17
+ emitEvent,
18
+ } = context;
19
+
20
+ const stepLogger = logger.child('BuildStep');
21
+
22
+ const latestRun = task.latest_run;
23
+ const prExists =
24
+ latestRun?.output && typeof latestRun.output === 'object'
25
+ ? (latestRun.output as any).pr_url
26
+ : null;
27
+
28
+ if (prExists) {
29
+ stepLogger.info('PR already exists, skipping build phase', { taskId: task.id });
30
+ return { status: 'skipped' };
31
+ }
32
+
33
+ stepLogger.info('Starting build phase', { taskId: task.id });
34
+ emitEvent(adapter.createStatusEvent('phase_start', { phase: 'build' }));
35
+
36
+ const executionPrompt = await promptBuilder.buildExecutionPrompt(task, cwd);
37
+ const fullPrompt = `${EXECUTION_SYSTEM_PROMPT}\n\n${executionPrompt}`;
38
+
39
+ const configuredPermissionMode =
40
+ options.permissionMode ??
41
+ (typeof step.permissionMode === 'string'
42
+ ? (step.permissionMode as PermissionMode)
43
+ : step.permissionMode) ??
44
+ PermissionMode.ACCEPT_EDITS;
45
+
46
+ const baseOptions: Record<string, any> = {
47
+ model: step.model,
48
+ cwd,
49
+ permissionMode: configuredPermissionMode,
50
+ settingSources: ['local'],
51
+ mcpServers,
52
+ };
53
+
54
+ const response = query({
55
+ prompt: fullPrompt,
56
+ options: { ...baseOptions, ...(options.queryOverrides || {}) },
57
+ });
58
+
59
+ for await (const message of response) {
60
+ emitEvent(adapter.createRawSDKEvent(message));
61
+ const transformed = adapter.transform(message);
62
+ if (transformed) {
63
+ emitEvent(transformed);
64
+ }
65
+ }
66
+
67
+ const hasChanges = await gitManager.hasChanges();
68
+ context.stepResults[step.id] = { commitCreated: false };
69
+ if (!hasChanges) {
70
+ stepLogger.warn('No changes to commit in build phase', { taskId: task.id });
71
+ emitEvent(adapter.createStatusEvent('phase_complete', { phase: 'build' }));
72
+ return { status: 'completed' };
73
+ }
74
+
75
+ await gitManager.addFiles(['.']);
76
+ const commitCreated = await finalizeStepGitActions(context, step, {
77
+ commitMessage: `Implementation for ${task.title}`,
78
+ });
79
+ context.stepResults[step.id] = { commitCreated };
80
+
81
+ if (!commitCreated) {
82
+ stepLogger.warn('No commit created during build step', { taskId: task.id });
83
+ }
84
+
85
+ emitEvent(adapter.createStatusEvent('phase_complete', { phase: 'build' }));
86
+ return { status: 'completed' };
87
+ };