crewly 1.12.1 → 1.13.1

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 (625) hide show
  1. package/config/skills/_common/complete-body-shape.test.sh +113 -0
  2. package/config/skills/_common/no-dangling-symlinks.test.sh +63 -0
  3. package/config/skills/_common/task-pool-body-shape.test.sh +471 -0
  4. package/config/skills/agent/core/accept-task/execute.sh +30 -5
  5. package/config/skills/agent/core/block-task/execute.sh +59 -6
  6. package/config/skills/agent/core/complete-task/SKILL.md +37 -5
  7. package/config/skills/agent/core/complete-task/execute.sh +40 -9
  8. package/config/skills/agent/core/complete-task/execute.test.sh +213 -0
  9. package/config/skills/agent/core/create-task/SKILL.md +33 -0
  10. package/config/skills/agent/core/create-task/execute.sh +82 -23
  11. package/config/skills/agent/core/delegate-task/execute.sh +46 -0
  12. package/config/skills/agent/core/get-team-norms/SKILL.md +1 -1
  13. package/config/skills/agent/core/get-team-norms/execute.sh +73 -2
  14. package/config/skills/agent/core/handoff-task/execute.sh +8 -1
  15. package/config/skills/agent/core/report-status/SKILL.md +26 -0
  16. package/config/skills/agent/core/report-status/execute.sh +40 -5
  17. package/config/skills/orchestrator/delegate-task/SKILL.md +1 -1
  18. package/config/skills/orchestrator/delegate-task/execute.sh +45 -11
  19. package/config/skills/orchestrator/delegate-task/execute.test.sh +153 -1
  20. package/config/skills/team-leader/aggregate-results/SKILL.md +1 -1
  21. package/config/skills/team-leader/decompose-goal/execute.sh +11 -16
  22. package/config/skills/team-leader/delegate-task/SKILL.md +14 -1
  23. package/config/skills/team-leader/delegate-task/execute.sh +132 -43
  24. package/config/skills/team-leader/delegate-task/execute.test.sh +180 -27
  25. package/config/vitest-exclude.constants.ts +56 -0
  26. package/dist/backend/backend/src/controllers/chat/chat.controller.d.ts.map +1 -1
  27. package/dist/backend/backend/src/controllers/chat/chat.controller.js +29 -7
  28. package/dist/backend/backend/src/controllers/chat/chat.controller.js.map +1 -1
  29. package/dist/backend/backend/src/controllers/cloud/cloud.controller.d.ts.map +1 -1
  30. package/dist/backend/backend/src/controllers/cloud/cloud.controller.js +1 -1
  31. package/dist/backend/backend/src/controllers/cloud/cloud.controller.js.map +1 -1
  32. package/dist/backend/backend/src/controllers/monitoring/terminal.controller.d.ts.map +1 -1
  33. package/dist/backend/backend/src/controllers/monitoring/terminal.controller.js +18 -3
  34. package/dist/backend/backend/src/controllers/monitoring/terminal.controller.js.map +1 -1
  35. package/dist/backend/backend/src/controllers/slack/slack.controller.d.ts.map +1 -1
  36. package/dist/backend/backend/src/controllers/slack/slack.controller.js +18 -15
  37. package/dist/backend/backend/src/controllers/slack/slack.controller.js.map +1 -1
  38. package/dist/backend/backend/src/controllers/task-pool/task-pool.controller.d.ts +6 -1
  39. package/dist/backend/backend/src/controllers/task-pool/task-pool.controller.d.ts.map +1 -1
  40. package/dist/backend/backend/src/controllers/task-pool/task-pool.controller.js +19 -10
  41. package/dist/backend/backend/src/controllers/task-pool/task-pool.controller.js.map +1 -1
  42. package/dist/backend/backend/src/index.d.ts.map +1 -1
  43. package/dist/backend/backend/src/index.js +20 -0
  44. package/dist/backend/backend/src/index.js.map +1 -1
  45. package/dist/backend/backend/src/scripts/stamp-build.d.ts +25 -0
  46. package/dist/backend/backend/src/scripts/stamp-build.d.ts.map +1 -0
  47. package/dist/backend/backend/src/scripts/stamp-build.js +48 -0
  48. package/dist/backend/backend/src/scripts/stamp-build.js.map +1 -0
  49. package/dist/backend/backend/src/services/agent/agent-registration.service.d.ts.map +1 -1
  50. package/dist/backend/backend/src/services/agent/agent-registration.service.js +33 -1
  51. package/dist/backend/backend/src/services/agent/agent-registration.service.js.map +1 -1
  52. package/dist/backend/backend/src/services/agent/crewly-agent/crewly-agent-external-runtime.service.d.ts +78 -2
  53. package/dist/backend/backend/src/services/agent/crewly-agent/crewly-agent-external-runtime.service.d.ts.map +1 -1
  54. package/dist/backend/backend/src/services/agent/crewly-agent/crewly-agent-external-runtime.service.js +248 -44
  55. package/dist/backend/backend/src/services/agent/crewly-agent/crewly-agent-external-runtime.service.js.map +1 -1
  56. package/dist/backend/backend/src/services/agent/crewly-agent/types.d.ts +51 -3
  57. package/dist/backend/backend/src/services/agent/crewly-agent/types.d.ts.map +1 -1
  58. package/dist/backend/backend/src/services/agent/crewly-agent/types.js +31 -1
  59. package/dist/backend/backend/src/services/agent/crewly-agent/types.js.map +1 -1
  60. package/dist/backend/backend/src/services/cloud/cloud-client.service.d.ts +5 -0
  61. package/dist/backend/backend/src/services/cloud/cloud-client.service.d.ts.map +1 -1
  62. package/dist/backend/backend/src/services/cloud/cloud-client.service.js +7 -0
  63. package/dist/backend/backend/src/services/cloud/cloud-client.service.js.map +1 -1
  64. package/dist/backend/backend/src/services/event-bus/event-to-workitem-bridge.service.d.ts +15 -0
  65. package/dist/backend/backend/src/services/event-bus/event-to-workitem-bridge.service.d.ts.map +1 -1
  66. package/dist/backend/backend/src/services/event-bus/event-to-workitem-bridge.service.js +40 -0
  67. package/dist/backend/backend/src/services/event-bus/event-to-workitem-bridge.service.js.map +1 -1
  68. package/dist/backend/backend/src/services/orchestrator/commitment-approval-guard.d.ts.map +1 -1
  69. package/dist/backend/backend/src/services/orchestrator/commitment-approval-guard.js +26 -0
  70. package/dist/backend/backend/src/services/orchestrator/commitment-approval-guard.js.map +1 -1
  71. package/dist/backend/backend/src/services/orchestrator/onboarding/materialize-team.d.ts.map +1 -1
  72. package/dist/backend/backend/src/services/orchestrator/onboarding/materialize-team.js +19 -3
  73. package/dist/backend/backend/src/services/orchestrator/onboarding/materialize-team.js.map +1 -1
  74. package/dist/backend/backend/src/services/orchestrator/orchestrator-status.service.d.ts +28 -3
  75. package/dist/backend/backend/src/services/orchestrator/orchestrator-status.service.d.ts.map +1 -1
  76. package/dist/backend/backend/src/services/orchestrator/orchestrator-status.service.js +65 -8
  77. package/dist/backend/backend/src/services/orchestrator/orchestrator-status.service.js.map +1 -1
  78. package/dist/backend/backend/src/services/reconciler/reconcile-rules.d.ts +214 -4
  79. package/dist/backend/backend/src/services/reconciler/reconcile-rules.d.ts.map +1 -1
  80. package/dist/backend/backend/src/services/reconciler/reconcile-rules.js +330 -48
  81. package/dist/backend/backend/src/services/reconciler/reconcile-rules.js.map +1 -1
  82. package/dist/backend/backend/src/services/reconciler/reconciler-data-provider.d.ts +13 -1
  83. package/dist/backend/backend/src/services/reconciler/reconciler-data-provider.d.ts.map +1 -1
  84. package/dist/backend/backend/src/services/reconciler/reconciler-data-provider.js +84 -5
  85. package/dist/backend/backend/src/services/reconciler/reconciler-data-provider.js.map +1 -1
  86. package/dist/backend/backend/src/services/reconciler/reconciler.service.d.ts +14 -0
  87. package/dist/backend/backend/src/services/reconciler/reconciler.service.d.ts.map +1 -1
  88. package/dist/backend/backend/src/services/reconciler/reconciler.service.js +77 -3
  89. package/dist/backend/backend/src/services/reconciler/reconciler.service.js.map +1 -1
  90. package/dist/backend/backend/src/services/task-pool/task-pool.service.d.ts +152 -7
  91. package/dist/backend/backend/src/services/task-pool/task-pool.service.d.ts.map +1 -1
  92. package/dist/backend/backend/src/services/task-pool/task-pool.service.js +268 -36
  93. package/dist/backend/backend/src/services/task-pool/task-pool.service.js.map +1 -1
  94. package/dist/backend/backend/src/services/v3/escalation-router.service.js +2 -2
  95. package/dist/backend/backend/src/services/v3/escalation-router.service.js.map +1 -1
  96. package/dist/backend/backend/src/services/v3/request-sla.subscriber.d.ts.map +1 -1
  97. package/dist/backend/backend/src/services/v3/request-sla.subscriber.js +39 -2
  98. package/dist/backend/backend/src/services/v3/request-sla.subscriber.js.map +1 -1
  99. package/dist/backend/backend/src/services/wiki/wiki-migrate.service.d.ts +3 -0
  100. package/dist/backend/backend/src/services/wiki/wiki-migrate.service.d.ts.map +1 -1
  101. package/dist/backend/backend/src/services/wiki/wiki-migrate.service.js +21 -10
  102. package/dist/backend/backend/src/services/wiki/wiki-migrate.service.js.map +1 -1
  103. package/dist/backend/backend/src/types/v2/index.d.ts +1 -1
  104. package/dist/backend/backend/src/types/v2/index.d.ts.map +1 -1
  105. package/dist/backend/backend/src/types/v2/index.js +1 -1
  106. package/dist/backend/backend/src/types/v2/index.js.map +1 -1
  107. package/dist/backend/backend/src/types/v2/work-item.types.d.ts +181 -1
  108. package/dist/backend/backend/src/types/v2/work-item.types.d.ts.map +1 -1
  109. package/dist/backend/backend/src/types/v2/work-item.types.js +104 -17
  110. package/dist/backend/backend/src/types/v2/work-item.types.js.map +1 -1
  111. package/dist/backend/backend/src/utils/build-provenance.d.ts +150 -0
  112. package/dist/backend/backend/src/utils/build-provenance.d.ts.map +1 -0
  113. package/dist/backend/backend/src/utils/build-provenance.js +211 -0
  114. package/dist/backend/backend/src/utils/build-provenance.js.map +1 -0
  115. package/dist/backend/backend/src/websocket/chat.gateway.d.ts.map +1 -1
  116. package/dist/backend/backend/src/websocket/chat.gateway.js +7 -1
  117. package/dist/backend/backend/src/websocket/chat.gateway.js.map +1 -1
  118. package/dist/backend/build-info.json +4 -0
  119. package/dist/backend/config/vitest-exclude.constants.d.ts +53 -0
  120. package/dist/backend/config/vitest-exclude.constants.d.ts.map +1 -0
  121. package/dist/backend/config/vitest-exclude.constants.js +55 -0
  122. package/dist/backend/config/vitest-exclude.constants.js.map +1 -0
  123. package/dist/cli/backend/src/services/agent/active-work-briefing.service.d.ts +538 -0
  124. package/dist/cli/backend/src/services/agent/active-work-briefing.service.d.ts.map +1 -0
  125. package/dist/cli/backend/src/services/agent/active-work-briefing.service.js +802 -0
  126. package/dist/cli/backend/src/services/agent/active-work-briefing.service.js.map +1 -0
  127. package/dist/cli/backend/src/services/agent/agent-heartbeat.service.d.ts +240 -0
  128. package/dist/cli/backend/src/services/agent/agent-heartbeat.service.d.ts.map +1 -0
  129. package/dist/cli/backend/src/services/agent/agent-heartbeat.service.js +524 -0
  130. package/dist/cli/backend/src/services/agent/agent-heartbeat.service.js.map +1 -0
  131. package/dist/cli/backend/src/services/agent/agent-registration.service.d.ts +629 -0
  132. package/dist/cli/backend/src/services/agent/agent-registration.service.d.ts.map +1 -0
  133. package/dist/cli/backend/src/services/agent/agent-registration.service.js +4548 -0
  134. package/dist/cli/backend/src/services/agent/agent-registration.service.js.map +1 -0
  135. package/dist/cli/backend/src/services/agent/agent-suspend.service.d.ts +118 -0
  136. package/dist/cli/backend/src/services/agent/agent-suspend.service.d.ts.map +1 -0
  137. package/dist/cli/backend/src/services/agent/agent-suspend.service.js +304 -0
  138. package/dist/cli/backend/src/services/agent/agent-suspend.service.js.map +1 -0
  139. package/dist/cli/backend/src/services/agent/auditor-scheduler.service.d.ts +196 -0
  140. package/dist/cli/backend/src/services/agent/auditor-scheduler.service.d.ts.map +1 -0
  141. package/dist/cli/backend/src/services/agent/auditor-scheduler.service.js +504 -0
  142. package/dist/cli/backend/src/services/agent/auditor-scheduler.service.js.map +1 -0
  143. package/dist/cli/backend/src/services/agent/claude-runtime.service.d.ts +97 -0
  144. package/dist/cli/backend/src/services/agent/claude-runtime.service.d.ts.map +1 -0
  145. package/dist/cli/backend/src/services/agent/claude-runtime.service.js +334 -0
  146. package/dist/cli/backend/src/services/agent/claude-runtime.service.js.map +1 -0
  147. package/dist/cli/backend/src/services/agent/codex-runtime.service.d.ts +47 -0
  148. package/dist/cli/backend/src/services/agent/codex-runtime.service.d.ts.map +1 -0
  149. package/dist/cli/backend/src/services/agent/codex-runtime.service.js +112 -0
  150. package/dist/cli/backend/src/services/agent/codex-runtime.service.js.map +1 -0
  151. package/dist/cli/backend/src/services/agent/context-window-monitor.service.d.ts +323 -0
  152. package/dist/cli/backend/src/services/agent/context-window-monitor.service.d.ts.map +1 -0
  153. package/dist/cli/backend/src/services/agent/context-window-monitor.service.js +1056 -0
  154. package/dist/cli/backend/src/services/agent/context-window-monitor.service.js.map +1 -0
  155. package/dist/cli/backend/src/services/agent/crewly-agent/crewly-agent-external-runtime.service.d.ts +198 -0
  156. package/dist/cli/backend/src/services/agent/crewly-agent/crewly-agent-external-runtime.service.d.ts.map +1 -0
  157. package/dist/cli/backend/src/services/agent/crewly-agent/crewly-agent-external-runtime.service.js +816 -0
  158. package/dist/cli/backend/src/services/agent/crewly-agent/crewly-agent-external-runtime.service.js.map +1 -0
  159. package/dist/cli/backend/src/services/agent/crewly-agent/in-process-log-buffer.d.ts +155 -0
  160. package/dist/cli/backend/src/services/agent/crewly-agent/in-process-log-buffer.d.ts.map +1 -0
  161. package/dist/cli/backend/src/services/agent/crewly-agent/in-process-log-buffer.js +272 -0
  162. package/dist/cli/backend/src/services/agent/crewly-agent/in-process-log-buffer.js.map +1 -0
  163. package/dist/cli/backend/src/services/agent/crewly-agent/in-process-runtime-registry.d.ts +91 -0
  164. package/dist/cli/backend/src/services/agent/crewly-agent/in-process-runtime-registry.d.ts.map +1 -0
  165. package/dist/cli/backend/src/services/agent/crewly-agent/in-process-runtime-registry.js +120 -0
  166. package/dist/cli/backend/src/services/agent/crewly-agent/in-process-runtime-registry.js.map +1 -0
  167. package/dist/cli/backend/src/services/agent/crewly-agent/types.d.ts +536 -0
  168. package/dist/cli/backend/src/services/agent/crewly-agent/types.d.ts.map +1 -0
  169. package/dist/cli/backend/src/services/agent/crewly-agent/types.js +282 -0
  170. package/dist/cli/backend/src/services/agent/crewly-agent/types.js.map +1 -0
  171. package/dist/cli/backend/src/services/agent/disk-cleanup.service.d.ts +100 -0
  172. package/dist/cli/backend/src/services/agent/disk-cleanup.service.d.ts.map +1 -0
  173. package/dist/cli/backend/src/services/agent/disk-cleanup.service.js +149 -0
  174. package/dist/cli/backend/src/services/agent/disk-cleanup.service.js.map +1 -0
  175. package/dist/cli/backend/src/services/agent/gemini-runtime.service.d.ts +130 -0
  176. package/dist/cli/backend/src/services/agent/gemini-runtime.service.d.ts.map +1 -0
  177. package/dist/cli/backend/src/services/agent/gemini-runtime.service.js +758 -0
  178. package/dist/cli/backend/src/services/agent/gemini-runtime.service.js.map +1 -0
  179. package/dist/cli/backend/src/services/agent/oauth-relogin-monitor.service.d.ts +216 -0
  180. package/dist/cli/backend/src/services/agent/oauth-relogin-monitor.service.d.ts.map +1 -0
  181. package/dist/cli/backend/src/services/agent/oauth-relogin-monitor.service.js +508 -0
  182. package/dist/cli/backend/src/services/agent/oauth-relogin-monitor.service.js.map +1 -0
  183. package/dist/cli/backend/src/services/agent/pty-activity-tracker.service.d.ts +113 -0
  184. package/dist/cli/backend/src/services/agent/pty-activity-tracker.service.d.ts.map +1 -0
  185. package/dist/cli/backend/src/services/agent/pty-activity-tracker.service.js +161 -0
  186. package/dist/cli/backend/src/services/agent/pty-activity-tracker.service.js.map +1 -0
  187. package/dist/cli/backend/src/services/agent/runtime-agent.service.abstract.d.ts +156 -0
  188. package/dist/cli/backend/src/services/agent/runtime-agent.service.abstract.d.ts.map +1 -0
  189. package/dist/cli/backend/src/services/agent/runtime-agent.service.abstract.js +641 -0
  190. package/dist/cli/backend/src/services/agent/runtime-agent.service.abstract.js.map +1 -0
  191. package/dist/cli/backend/src/services/agent/runtime-exit-monitor.service.d.ts +295 -0
  192. package/dist/cli/backend/src/services/agent/runtime-exit-monitor.service.d.ts.map +1 -0
  193. package/dist/cli/backend/src/services/agent/runtime-exit-monitor.service.js +1166 -0
  194. package/dist/cli/backend/src/services/agent/runtime-exit-monitor.service.js.map +1 -0
  195. package/dist/cli/backend/src/services/agent/runtime-service.factory.d.ts +71 -0
  196. package/dist/cli/backend/src/services/agent/runtime-service.factory.d.ts.map +1 -0
  197. package/dist/cli/backend/src/services/agent/runtime-service.factory.js +174 -0
  198. package/dist/cli/backend/src/services/agent/runtime-service.factory.js.map +1 -0
  199. package/dist/cli/backend/src/services/ai/prompt-builder.service.d.ts +435 -0
  200. package/dist/cli/backend/src/services/ai/prompt-builder.service.d.ts.map +1 -0
  201. package/dist/cli/backend/src/services/ai/prompt-builder.service.js +1331 -0
  202. package/dist/cli/backend/src/services/ai/prompt-builder.service.js.map +1 -0
  203. package/dist/cli/backend/src/services/ai/prompt-modules/capability-overlay.module.d.ts +33 -0
  204. package/dist/cli/backend/src/services/ai/prompt-modules/capability-overlay.module.d.ts.map +1 -0
  205. package/dist/cli/backend/src/services/ai/prompt-modules/capability-overlay.module.js +70 -0
  206. package/dist/cli/backend/src/services/ai/prompt-modules/capability-overlay.module.js.map +1 -0
  207. package/dist/cli/backend/src/services/ai/prompt-modules/communication.module.d.ts +100 -0
  208. package/dist/cli/backend/src/services/ai/prompt-modules/communication.module.d.ts.map +1 -0
  209. package/dist/cli/backend/src/services/ai/prompt-modules/communication.module.js +296 -0
  210. package/dist/cli/backend/src/services/ai/prompt-modules/communication.module.js.map +1 -0
  211. package/dist/cli/backend/src/services/ai/prompt-modules/decision-rights.module.d.ts +59 -0
  212. package/dist/cli/backend/src/services/ai/prompt-modules/decision-rights.module.d.ts.map +1 -0
  213. package/dist/cli/backend/src/services/ai/prompt-modules/decision-rights.module.js +87 -0
  214. package/dist/cli/backend/src/services/ai/prompt-modules/decision-rights.module.js.map +1 -0
  215. package/dist/cli/backend/src/services/ai/prompt-modules/default-execution-loop.module.d.ts +67 -0
  216. package/dist/cli/backend/src/services/ai/prompt-modules/default-execution-loop.module.d.ts.map +1 -0
  217. package/dist/cli/backend/src/services/ai/prompt-modules/default-execution-loop.module.js +84 -0
  218. package/dist/cli/backend/src/services/ai/prompt-modules/default-execution-loop.module.js.map +1 -0
  219. package/dist/cli/backend/src/services/ai/prompt-modules/domain-sop.module.d.ts +35 -0
  220. package/dist/cli/backend/src/services/ai/prompt-modules/domain-sop.module.d.ts.map +1 -0
  221. package/dist/cli/backend/src/services/ai/prompt-modules/domain-sop.module.js +50 -0
  222. package/dist/cli/backend/src/services/ai/prompt-modules/domain-sop.module.js.map +1 -0
  223. package/dist/cli/backend/src/services/ai/prompt-modules/expert-profile.module.d.ts +41 -0
  224. package/dist/cli/backend/src/services/ai/prompt-modules/expert-profile.module.d.ts.map +1 -0
  225. package/dist/cli/backend/src/services/ai/prompt-modules/expert-profile.module.js +95 -0
  226. package/dist/cli/backend/src/services/ai/prompt-modules/expert-profile.module.js.map +1 -0
  227. package/dist/cli/backend/src/services/ai/prompt-modules/identity.module.d.ts +28 -0
  228. package/dist/cli/backend/src/services/ai/prompt-modules/identity.module.d.ts.map +1 -0
  229. package/dist/cli/backend/src/services/ai/prompt-modules/identity.module.js +47 -0
  230. package/dist/cli/backend/src/services/ai/prompt-modules/identity.module.js.map +1 -0
  231. package/dist/cli/backend/src/services/ai/prompt-modules/lazy-anti-patterns.module.d.ts +65 -0
  232. package/dist/cli/backend/src/services/ai/prompt-modules/lazy-anti-patterns.module.d.ts.map +1 -0
  233. package/dist/cli/backend/src/services/ai/prompt-modules/lazy-anti-patterns.module.js +79 -0
  234. package/dist/cli/backend/src/services/ai/prompt-modules/lazy-anti-patterns.module.js.map +1 -0
  235. package/dist/cli/backend/src/services/ai/prompt-modules/learning-reference.module.d.ts +28 -0
  236. package/dist/cli/backend/src/services/ai/prompt-modules/learning-reference.module.d.ts.map +1 -0
  237. package/dist/cli/backend/src/services/ai/prompt-modules/learning-reference.module.js +55 -0
  238. package/dist/cli/backend/src/services/ai/prompt-modules/learning-reference.module.js.map +1 -0
  239. package/dist/cli/backend/src/services/ai/prompt-modules/lifecycle.module.d.ts +44 -0
  240. package/dist/cli/backend/src/services/ai/prompt-modules/lifecycle.module.d.ts.map +1 -0
  241. package/dist/cli/backend/src/services/ai/prompt-modules/lifecycle.module.js +120 -0
  242. package/dist/cli/backend/src/services/ai/prompt-modules/lifecycle.module.js.map +1 -0
  243. package/dist/cli/backend/src/services/ai/prompt-modules/markdown-file-module.d.ts +46 -0
  244. package/dist/cli/backend/src/services/ai/prompt-modules/markdown-file-module.d.ts.map +1 -0
  245. package/dist/cli/backend/src/services/ai/prompt-modules/markdown-file-module.js +44 -0
  246. package/dist/cli/backend/src/services/ai/prompt-modules/markdown-file-module.js.map +1 -0
  247. package/dist/cli/backend/src/services/ai/prompt-modules/memory-reference.module.d.ts +28 -0
  248. package/dist/cli/backend/src/services/ai/prompt-modules/memory-reference.module.d.ts.map +1 -0
  249. package/dist/cli/backend/src/services/ai/prompt-modules/memory-reference.module.js +46 -0
  250. package/dist/cli/backend/src/services/ai/prompt-modules/memory-reference.module.js.map +1 -0
  251. package/dist/cli/backend/src/services/ai/prompt-modules/mission-context.module.d.ts +60 -0
  252. package/dist/cli/backend/src/services/ai/prompt-modules/mission-context.module.d.ts.map +1 -0
  253. package/dist/cli/backend/src/services/ai/prompt-modules/mission-context.module.js +104 -0
  254. package/dist/cli/backend/src/services/ai/prompt-modules/mission-context.module.js.map +1 -0
  255. package/dist/cli/backend/src/services/ai/prompt-modules/project-reference.module.d.ts +29 -0
  256. package/dist/cli/backend/src/services/ai/prompt-modules/project-reference.module.d.ts.map +1 -0
  257. package/dist/cli/backend/src/services/ai/prompt-modules/project-reference.module.js +50 -0
  258. package/dist/cli/backend/src/services/ai/prompt-modules/project-reference.module.js.map +1 -0
  259. package/dist/cli/backend/src/services/ai/prompt-modules/prompt-assembly.service.d.ts +103 -0
  260. package/dist/cli/backend/src/services/ai/prompt-modules/prompt-assembly.service.d.ts.map +1 -0
  261. package/dist/cli/backend/src/services/ai/prompt-modules/prompt-assembly.service.js +383 -0
  262. package/dist/cli/backend/src/services/ai/prompt-modules/prompt-assembly.service.js.map +1 -0
  263. package/dist/cli/backend/src/services/ai/prompt-modules/recovery.module.d.ts +34 -0
  264. package/dist/cli/backend/src/services/ai/prompt-modules/recovery.module.d.ts.map +1 -0
  265. package/dist/cli/backend/src/services/ai/prompt-modules/recovery.module.js +96 -0
  266. package/dist/cli/backend/src/services/ai/prompt-modules/recovery.module.js.map +1 -0
  267. package/dist/cli/backend/src/services/ai/prompt-modules/request-contract.module.d.ts +106 -0
  268. package/dist/cli/backend/src/services/ai/prompt-modules/request-contract.module.d.ts.map +1 -0
  269. package/dist/cli/backend/src/services/ai/prompt-modules/request-contract.module.js +167 -0
  270. package/dist/cli/backend/src/services/ai/prompt-modules/request-contract.module.js.map +1 -0
  271. package/dist/cli/backend/src/services/ai/prompt-modules/risk-policy.module.d.ts +35 -0
  272. package/dist/cli/backend/src/services/ai/prompt-modules/risk-policy.module.d.ts.map +1 -0
  273. package/dist/cli/backend/src/services/ai/prompt-modules/risk-policy.module.js +50 -0
  274. package/dist/cli/backend/src/services/ai/prompt-modules/risk-policy.module.js.map +1 -0
  275. package/dist/cli/backend/src/services/ai/prompt-modules/role-boundary.module.d.ts +91 -0
  276. package/dist/cli/backend/src/services/ai/prompt-modules/role-boundary.module.d.ts.map +1 -0
  277. package/dist/cli/backend/src/services/ai/prompt-modules/role-boundary.module.js +411 -0
  278. package/dist/cli/backend/src/services/ai/prompt-modules/role-boundary.module.js.map +1 -0
  279. package/dist/cli/backend/src/services/ai/prompt-modules/skills-reference.module.d.ts +62 -0
  280. package/dist/cli/backend/src/services/ai/prompt-modules/skills-reference.module.d.ts.map +1 -0
  281. package/dist/cli/backend/src/services/ai/prompt-modules/skills-reference.module.js +199 -0
  282. package/dist/cli/backend/src/services/ai/prompt-modules/skills-reference.module.js.map +1 -0
  283. package/dist/cli/backend/src/services/ai/prompt-modules/sop-norm-distinction.module.d.ts +79 -0
  284. package/dist/cli/backend/src/services/ai/prompt-modules/sop-norm-distinction.module.d.ts.map +1 -0
  285. package/dist/cli/backend/src/services/ai/prompt-modules/sop-norm-distinction.module.js +118 -0
  286. package/dist/cli/backend/src/services/ai/prompt-modules/sop-norm-distinction.module.js.map +1 -0
  287. package/dist/cli/backend/src/services/ai/prompt-modules/soul.module.d.ts +102 -0
  288. package/dist/cli/backend/src/services/ai/prompt-modules/soul.module.d.ts.map +1 -0
  289. package/dist/cli/backend/src/services/ai/prompt-modules/soul.module.js +229 -0
  290. package/dist/cli/backend/src/services/ai/prompt-modules/soul.module.js.map +1 -0
  291. package/dist/cli/backend/src/services/ai/prompt-modules/team-norms.module.d.ts +61 -0
  292. package/dist/cli/backend/src/services/ai/prompt-modules/team-norms.module.d.ts.map +1 -0
  293. package/dist/cli/backend/src/services/ai/prompt-modules/team-norms.module.js +197 -0
  294. package/dist/cli/backend/src/services/ai/prompt-modules/team-norms.module.js.map +1 -0
  295. package/dist/cli/backend/src/services/ai/prompt-modules/team-reference.module.d.ts +54 -0
  296. package/dist/cli/backend/src/services/ai/prompt-modules/team-reference.module.d.ts.map +1 -0
  297. package/dist/cli/backend/src/services/ai/prompt-modules/team-reference.module.js +149 -0
  298. package/dist/cli/backend/src/services/ai/prompt-modules/team-reference.module.js.map +1 -0
  299. package/dist/cli/backend/src/services/ai/prompt-modules/user-profile-reference.module.d.ts +32 -0
  300. package/dist/cli/backend/src/services/ai/prompt-modules/user-profile-reference.module.d.ts.map +1 -0
  301. package/dist/cli/backend/src/services/ai/prompt-modules/user-profile-reference.module.js +69 -0
  302. package/dist/cli/backend/src/services/ai/prompt-modules/user-profile-reference.module.js.map +1 -0
  303. package/dist/cli/backend/src/services/ai/prompt-modules/working-memory.module.d.ts +91 -0
  304. package/dist/cli/backend/src/services/ai/prompt-modules/working-memory.module.d.ts.map +1 -0
  305. package/dist/cli/backend/src/services/ai/prompt-modules/working-memory.module.js +136 -0
  306. package/dist/cli/backend/src/services/ai/prompt-modules/working-memory.module.js.map +1 -0
  307. package/dist/cli/backend/src/services/ai/self-improvement/growth-areas.service.d.ts +81 -0
  308. package/dist/cli/backend/src/services/ai/self-improvement/growth-areas.service.d.ts.map +1 -0
  309. package/dist/cli/backend/src/services/ai/self-improvement/growth-areas.service.js +135 -0
  310. package/dist/cli/backend/src/services/ai/self-improvement/growth-areas.service.js.map +1 -0
  311. package/dist/cli/backend/src/services/chat-v2/chat-v2.service.d.ts +737 -0
  312. package/dist/cli/backend/src/services/chat-v2/chat-v2.service.d.ts.map +1 -0
  313. package/dist/cli/backend/src/services/chat-v2/chat-v2.service.js +1213 -0
  314. package/dist/cli/backend/src/services/chat-v2/chat-v2.service.js.map +1 -0
  315. package/dist/cli/backend/src/services/chat-v2/chat-v2.singleton.d.ts +27 -0
  316. package/dist/cli/backend/src/services/chat-v2/chat-v2.singleton.d.ts.map +1 -0
  317. package/dist/cli/backend/src/services/chat-v2/chat-v2.singleton.js +57 -0
  318. package/dist/cli/backend/src/services/chat-v2/chat-v2.singleton.js.map +1 -0
  319. package/dist/cli/backend/src/services/chat-v2/config.d.ts +100 -0
  320. package/dist/cli/backend/src/services/chat-v2/config.d.ts.map +1 -0
  321. package/dist/cli/backend/src/services/chat-v2/config.js +174 -0
  322. package/dist/cli/backend/src/services/chat-v2/config.js.map +1 -0
  323. package/dist/cli/backend/src/services/chat-v2/legacy-dto.utils.d.ts +118 -0
  324. package/dist/cli/backend/src/services/chat-v2/legacy-dto.utils.d.ts.map +1 -0
  325. package/dist/cli/backend/src/services/chat-v2/legacy-dto.utils.js +171 -0
  326. package/dist/cli/backend/src/services/chat-v2/legacy-dto.utils.js.map +1 -0
  327. package/dist/cli/backend/src/services/chat-v2/sqlite/channel.store.d.ts +188 -0
  328. package/dist/cli/backend/src/services/chat-v2/sqlite/channel.store.d.ts.map +1 -0
  329. package/dist/cli/backend/src/services/chat-v2/sqlite/channel.store.js +317 -0
  330. package/dist/cli/backend/src/services/chat-v2/sqlite/channel.store.js.map +1 -0
  331. package/dist/cli/backend/src/services/chat-v2/sqlite/chat-db.d.ts +119 -0
  332. package/dist/cli/backend/src/services/chat-v2/sqlite/chat-db.d.ts.map +1 -0
  333. package/dist/cli/backend/src/services/chat-v2/sqlite/chat-db.js +551 -0
  334. package/dist/cli/backend/src/services/chat-v2/sqlite/chat-db.js.map +1 -0
  335. package/dist/cli/backend/src/services/chat-v2/sqlite/message.store.d.ts +208 -0
  336. package/dist/cli/backend/src/services/chat-v2/sqlite/message.store.d.ts.map +1 -0
  337. package/dist/cli/backend/src/services/chat-v2/sqlite/message.store.js +405 -0
  338. package/dist/cli/backend/src/services/chat-v2/sqlite/message.store.js.map +1 -0
  339. package/dist/cli/backend/src/services/chat-v2/types.d.ts +341 -0
  340. package/dist/cli/backend/src/services/chat-v2/types.d.ts.map +1 -0
  341. package/dist/cli/backend/src/services/chat-v2/types.js +61 -0
  342. package/dist/cli/backend/src/services/chat-v2/types.js.map +1 -0
  343. package/dist/cli/backend/src/services/cloud/cloud-client.service.d.ts +5 -0
  344. package/dist/cli/backend/src/services/cloud/cloud-client.service.d.ts.map +1 -1
  345. package/dist/cli/backend/src/services/cloud/cloud-client.service.js +7 -0
  346. package/dist/cli/backend/src/services/cloud/cloud-client.service.js.map +1 -1
  347. package/dist/cli/backend/src/services/continuation/patterns/idle-patterns.d.ts +37 -0
  348. package/dist/cli/backend/src/services/continuation/patterns/idle-patterns.d.ts.map +1 -0
  349. package/dist/cli/backend/src/services/continuation/patterns/idle-patterns.js +63 -0
  350. package/dist/cli/backend/src/services/continuation/patterns/idle-patterns.js.map +1 -0
  351. package/dist/cli/backend/src/services/intent-task/intent-classifier.rules.d.ts +335 -0
  352. package/dist/cli/backend/src/services/intent-task/intent-classifier.rules.d.ts.map +1 -0
  353. package/dist/cli/backend/src/services/intent-task/intent-classifier.rules.js +421 -0
  354. package/dist/cli/backend/src/services/intent-task/intent-classifier.rules.js.map +1 -0
  355. package/dist/cli/backend/src/services/mcp-client.d.ts +233 -0
  356. package/dist/cli/backend/src/services/mcp-client.d.ts.map +1 -0
  357. package/dist/cli/backend/src/services/mcp-client.js +302 -0
  358. package/dist/cli/backend/src/services/mcp-client.js.map +1 -0
  359. package/dist/cli/backend/src/services/memory/mission-context.service.d.ts +168 -0
  360. package/dist/cli/backend/src/services/memory/mission-context.service.d.ts.map +1 -0
  361. package/dist/cli/backend/src/services/memory/mission-context.service.js +365 -0
  362. package/dist/cli/backend/src/services/memory/mission-context.service.js.map +1 -0
  363. package/dist/cli/backend/src/services/memory/session-memory.service.d.ts +197 -0
  364. package/dist/cli/backend/src/services/memory/session-memory.service.d.ts.map +1 -0
  365. package/dist/cli/backend/src/services/memory/session-memory.service.js +369 -0
  366. package/dist/cli/backend/src/services/memory/session-memory.service.js.map +1 -0
  367. package/dist/cli/backend/src/services/memory/user-profile.service.d.ts +77 -0
  368. package/dist/cli/backend/src/services/memory/user-profile.service.d.ts.map +1 -0
  369. package/dist/cli/backend/src/services/memory/user-profile.service.js +171 -0
  370. package/dist/cli/backend/src/services/memory/user-profile.service.js.map +1 -0
  371. package/dist/cli/backend/src/services/memory/working-memory.service.d.ts +232 -0
  372. package/dist/cli/backend/src/services/memory/working-memory.service.d.ts.map +1 -0
  373. package/dist/cli/backend/src/services/memory/working-memory.service.js +417 -0
  374. package/dist/cli/backend/src/services/memory/working-memory.service.js.map +1 -0
  375. package/dist/cli/backend/src/services/messaging/sub-agent-message-queue.service.d.ts +84 -0
  376. package/dist/cli/backend/src/services/messaging/sub-agent-message-queue.service.d.ts.map +1 -0
  377. package/dist/cli/backend/src/services/messaging/sub-agent-message-queue.service.js +136 -0
  378. package/dist/cli/backend/src/services/messaging/sub-agent-message-queue.service.js.map +1 -0
  379. package/dist/cli/backend/src/services/messaging/thread-status-queue.service.d.ts +358 -0
  380. package/dist/cli/backend/src/services/messaging/thread-status-queue.service.d.ts.map +1 -0
  381. package/dist/cli/backend/src/services/messaging/thread-status-queue.service.js +755 -0
  382. package/dist/cli/backend/src/services/messaging/thread-status-queue.service.js.map +1 -0
  383. package/dist/cli/backend/src/services/monitoring/token-usage.service.d.ts +269 -0
  384. package/dist/cli/backend/src/services/monitoring/token-usage.service.d.ts.map +1 -0
  385. package/dist/cli/backend/src/services/monitoring/token-usage.service.js +391 -0
  386. package/dist/cli/backend/src/services/monitoring/token-usage.service.js.map +1 -0
  387. package/dist/cli/backend/src/services/observability/agent-behavior-log.service.d.ts +132 -0
  388. package/dist/cli/backend/src/services/observability/agent-behavior-log.service.d.ts.map +1 -0
  389. package/dist/cli/backend/src/services/observability/agent-behavior-log.service.js +284 -0
  390. package/dist/cli/backend/src/services/observability/agent-behavior-log.service.js.map +1 -0
  391. package/dist/cli/backend/src/services/observability/agent-behavior-log.singleton.d.ts +70 -0
  392. package/dist/cli/backend/src/services/observability/agent-behavior-log.singleton.d.ts.map +1 -0
  393. package/dist/cli/backend/src/services/observability/agent-behavior-log.singleton.js +121 -0
  394. package/dist/cli/backend/src/services/observability/agent-behavior-log.singleton.js.map +1 -0
  395. package/dist/cli/backend/src/services/observability/agent-behavior-log.types.d.ts +130 -0
  396. package/dist/cli/backend/src/services/observability/agent-behavior-log.types.d.ts.map +1 -0
  397. package/dist/cli/backend/src/services/observability/agent-behavior-log.types.js +48 -0
  398. package/dist/cli/backend/src/services/observability/agent-behavior-log.types.js.map +1 -0
  399. package/dist/cli/backend/src/services/observability/observability-db.d.ts +84 -0
  400. package/dist/cli/backend/src/services/observability/observability-db.d.ts.map +1 -0
  401. package/dist/cli/backend/src/services/observability/observability-db.js +165 -0
  402. package/dist/cli/backend/src/services/observability/observability-db.js.map +1 -0
  403. package/dist/cli/backend/src/services/onboarding/content-approval.service.d.ts +124 -0
  404. package/dist/cli/backend/src/services/onboarding/content-approval.service.d.ts.map +1 -0
  405. package/dist/cli/backend/src/services/onboarding/content-approval.service.js +256 -0
  406. package/dist/cli/backend/src/services/onboarding/content-approval.service.js.map +1 -0
  407. package/dist/cli/backend/src/services/onboarding/content-approval.types.d.ts +80 -0
  408. package/dist/cli/backend/src/services/onboarding/content-approval.types.d.ts.map +1 -0
  409. package/dist/cli/backend/src/services/onboarding/content-approval.types.js +16 -0
  410. package/dist/cli/backend/src/services/onboarding/content-approval.types.js.map +1 -0
  411. package/dist/cli/backend/src/services/orc/orc-delivery-enforcer.service.d.ts +142 -0
  412. package/dist/cli/backend/src/services/orc/orc-delivery-enforcer.service.d.ts.map +1 -0
  413. package/dist/cli/backend/src/services/orc/orc-delivery-enforcer.service.js +265 -0
  414. package/dist/cli/backend/src/services/orc/orc-delivery-enforcer.service.js.map +1 -0
  415. package/dist/cli/backend/src/services/orchestrator/improvement-marker.service.d.ts +231 -0
  416. package/dist/cli/backend/src/services/orchestrator/improvement-marker.service.d.ts.map +1 -0
  417. package/dist/cli/backend/src/services/orchestrator/improvement-marker.service.js +353 -0
  418. package/dist/cli/backend/src/services/orchestrator/improvement-marker.service.js.map +1 -0
  419. package/dist/cli/backend/src/services/orchestrator/improvement-startup.service.d.ts +157 -0
  420. package/dist/cli/backend/src/services/orchestrator/improvement-startup.service.d.ts.map +1 -0
  421. package/dist/cli/backend/src/services/orchestrator/improvement-startup.service.js +483 -0
  422. package/dist/cli/backend/src/services/orchestrator/improvement-startup.service.js.map +1 -0
  423. package/dist/cli/backend/src/services/orchestrator/index.d.ts +16 -0
  424. package/dist/cli/backend/src/services/orchestrator/index.d.ts.map +1 -0
  425. package/dist/cli/backend/src/services/orchestrator/index.js +16 -0
  426. package/dist/cli/backend/src/services/orchestrator/index.js.map +1 -0
  427. package/dist/cli/backend/src/services/orchestrator/orchestrator-restart.service.d.ts +117 -0
  428. package/dist/cli/backend/src/services/orchestrator/orchestrator-restart.service.d.ts.map +1 -0
  429. package/dist/cli/backend/src/services/orchestrator/orchestrator-restart.service.js +300 -0
  430. package/dist/cli/backend/src/services/orchestrator/orchestrator-restart.service.js.map +1 -0
  431. package/dist/cli/backend/src/services/orchestrator/orchestrator-setup.service.d.ts +114 -0
  432. package/dist/cli/backend/src/services/orchestrator/orchestrator-setup.service.d.ts.map +1 -0
  433. package/dist/cli/backend/src/services/orchestrator/orchestrator-setup.service.js +195 -0
  434. package/dist/cli/backend/src/services/orchestrator/orchestrator-setup.service.js.map +1 -0
  435. package/dist/cli/backend/src/services/orchestrator/orchestrator-status.service.d.ts +94 -0
  436. package/dist/cli/backend/src/services/orchestrator/orchestrator-status.service.d.ts.map +1 -0
  437. package/dist/cli/backend/src/services/orchestrator/orchestrator-status.service.js +279 -0
  438. package/dist/cli/backend/src/services/orchestrator/orchestrator-status.service.js.map +1 -0
  439. package/dist/cli/backend/src/services/orchestrator/safe-restart.service.d.ts +192 -0
  440. package/dist/cli/backend/src/services/orchestrator/safe-restart.service.d.ts.map +1 -0
  441. package/dist/cli/backend/src/services/orchestrator/safe-restart.service.js +395 -0
  442. package/dist/cli/backend/src/services/orchestrator/safe-restart.service.js.map +1 -0
  443. package/dist/cli/backend/src/services/orchestrator/self-improvement.service.d.ts +201 -0
  444. package/dist/cli/backend/src/services/orchestrator/self-improvement.service.d.ts.map +1 -0
  445. package/dist/cli/backend/src/services/orchestrator/self-improvement.service.js +396 -0
  446. package/dist/cli/backend/src/services/orchestrator/self-improvement.service.js.map +1 -0
  447. package/dist/cli/backend/src/services/orchestrator/slack-bridge-lazy.d.ts +17 -0
  448. package/dist/cli/backend/src/services/orchestrator/slack-bridge-lazy.d.ts.map +1 -0
  449. package/dist/cli/backend/src/services/orchestrator/slack-bridge-lazy.js +30 -0
  450. package/dist/cli/backend/src/services/orchestrator/slack-bridge-lazy.js.map +1 -0
  451. package/dist/cli/backend/src/services/orchestrator/state-persistence.service.d.ts +249 -0
  452. package/dist/cli/backend/src/services/orchestrator/state-persistence.service.d.ts.map +1 -0
  453. package/dist/cli/backend/src/services/orchestrator/state-persistence.service.js +569 -0
  454. package/dist/cli/backend/src/services/orchestrator/state-persistence.service.js.map +1 -0
  455. package/dist/cli/backend/src/services/session/index.d.ts +47 -0
  456. package/dist/cli/backend/src/services/session/index.d.ts.map +1 -0
  457. package/dist/cli/backend/src/services/session/index.js +50 -0
  458. package/dist/cli/backend/src/services/session/index.js.map +1 -0
  459. package/dist/cli/backend/src/services/session/log-rotation.service.d.ts +163 -0
  460. package/dist/cli/backend/src/services/session/log-rotation.service.d.ts.map +1 -0
  461. package/dist/cli/backend/src/services/session/log-rotation.service.js +362 -0
  462. package/dist/cli/backend/src/services/session/log-rotation.service.js.map +1 -0
  463. package/dist/cli/backend/src/services/session/pty/index.d.ts +11 -0
  464. package/dist/cli/backend/src/services/session/pty/index.d.ts.map +1 -0
  465. package/dist/cli/backend/src/services/session/pty/index.js +11 -0
  466. package/dist/cli/backend/src/services/session/pty/index.js.map +1 -0
  467. package/dist/cli/backend/src/services/session/pty/pty-session-backend.d.ts +445 -0
  468. package/dist/cli/backend/src/services/session/pty/pty-session-backend.d.ts.map +1 -0
  469. package/dist/cli/backend/src/services/session/pty/pty-session-backend.js +804 -0
  470. package/dist/cli/backend/src/services/session/pty/pty-session-backend.js.map +1 -0
  471. package/dist/cli/backend/src/services/session/pty/pty-session.d.ts +252 -0
  472. package/dist/cli/backend/src/services/session/pty/pty-session.d.ts.map +1 -0
  473. package/dist/cli/backend/src/services/session/pty/pty-session.js +611 -0
  474. package/dist/cli/backend/src/services/session/pty/pty-session.js.map +1 -0
  475. package/dist/cli/backend/src/services/session/pty/pty-terminal-buffer.d.ts +275 -0
  476. package/dist/cli/backend/src/services/session/pty/pty-terminal-buffer.d.ts.map +1 -0
  477. package/dist/cli/backend/src/services/session/pty/pty-terminal-buffer.js +403 -0
  478. package/dist/cli/backend/src/services/session/pty/pty-terminal-buffer.js.map +1 -0
  479. package/dist/cli/backend/src/services/session/runtime-pid-registry.service.d.ts +86 -0
  480. package/dist/cli/backend/src/services/session/runtime-pid-registry.service.d.ts.map +1 -0
  481. package/dist/cli/backend/src/services/session/runtime-pid-registry.service.js +214 -0
  482. package/dist/cli/backend/src/services/session/runtime-pid-registry.service.js.map +1 -0
  483. package/dist/cli/backend/src/services/session/session-backend.factory.d.ts +127 -0
  484. package/dist/cli/backend/src/services/session/session-backend.factory.d.ts.map +1 -0
  485. package/dist/cli/backend/src/services/session/session-backend.factory.js +226 -0
  486. package/dist/cli/backend/src/services/session/session-backend.factory.js.map +1 -0
  487. package/dist/cli/backend/src/services/session/session-backend.interface.d.ts +390 -0
  488. package/dist/cli/backend/src/services/session/session-backend.interface.d.ts.map +1 -0
  489. package/dist/cli/backend/src/services/session/session-backend.interface.js +19 -0
  490. package/dist/cli/backend/src/services/session/session-backend.interface.js.map +1 -0
  491. package/dist/cli/backend/src/services/session/session-command-helper.d.ts +350 -0
  492. package/dist/cli/backend/src/services/session/session-command-helper.d.ts.map +1 -0
  493. package/dist/cli/backend/src/services/session/session-command-helper.js +810 -0
  494. package/dist/cli/backend/src/services/session/session-command-helper.js.map +1 -0
  495. package/dist/cli/backend/src/services/session/session-handoff.service.d.ts +307 -0
  496. package/dist/cli/backend/src/services/session/session-handoff.service.d.ts.map +1 -0
  497. package/dist/cli/backend/src/services/session/session-handoff.service.js +742 -0
  498. package/dist/cli/backend/src/services/session/session-handoff.service.js.map +1 -0
  499. package/dist/cli/backend/src/services/session/session-state-persistence.d.ts +231 -0
  500. package/dist/cli/backend/src/services/session/session-state-persistence.d.ts.map +1 -0
  501. package/dist/cli/backend/src/services/session/session-state-persistence.js +407 -0
  502. package/dist/cli/backend/src/services/session/session-state-persistence.js.map +1 -0
  503. package/dist/cli/backend/src/services/settings/role.service.d.ts +277 -0
  504. package/dist/cli/backend/src/services/settings/role.service.d.ts.map +1 -0
  505. package/dist/cli/backend/src/services/settings/role.service.js +728 -0
  506. package/dist/cli/backend/src/services/settings/role.service.js.map +1 -0
  507. package/dist/cli/backend/src/services/slack/cross-machine-message.service.d.ts +152 -0
  508. package/dist/cli/backend/src/services/slack/cross-machine-message.service.d.ts.map +1 -0
  509. package/dist/cli/backend/src/services/slack/cross-machine-message.service.js +354 -0
  510. package/dist/cli/backend/src/services/slack/cross-machine-message.service.js.map +1 -0
  511. package/dist/cli/backend/src/services/slack/slack-image.service.d.ts +114 -0
  512. package/dist/cli/backend/src/services/slack/slack-image.service.d.ts.map +1 -0
  513. package/dist/cli/backend/src/services/slack/slack-image.service.js +331 -0
  514. package/dist/cli/backend/src/services/slack/slack-image.service.js.map +1 -0
  515. package/dist/cli/backend/src/services/slack/slack-orchestrator-bridge.d.ts +499 -0
  516. package/dist/cli/backend/src/services/slack/slack-orchestrator-bridge.d.ts.map +1 -0
  517. package/dist/cli/backend/src/services/slack/slack-orchestrator-bridge.js +1928 -0
  518. package/dist/cli/backend/src/services/slack/slack-orchestrator-bridge.js.map +1 -0
  519. package/dist/cli/backend/src/services/slack/slack.service.d.ts +315 -0
  520. package/dist/cli/backend/src/services/slack/slack.service.d.ts.map +1 -0
  521. package/dist/cli/backend/src/services/slack/slack.service.js +1094 -0
  522. package/dist/cli/backend/src/services/slack/slack.service.js.map +1 -0
  523. package/dist/cli/backend/src/services/sop/sop.service.d.ts +364 -0
  524. package/dist/cli/backend/src/services/sop/sop.service.d.ts.map +1 -0
  525. package/dist/cli/backend/src/services/sop/sop.service.js +734 -0
  526. package/dist/cli/backend/src/services/sop/sop.service.js.map +1 -0
  527. package/dist/cli/backend/src/services/task-pool/task-pool.service.d.ts +152 -7
  528. package/dist/cli/backend/src/services/task-pool/task-pool.service.d.ts.map +1 -1
  529. package/dist/cli/backend/src/services/task-pool/task-pool.service.js +268 -36
  530. package/dist/cli/backend/src/services/task-pool/task-pool.service.js.map +1 -1
  531. package/dist/cli/backend/src/services/v3/escalation-router.service.d.ts +178 -0
  532. package/dist/cli/backend/src/services/v3/escalation-router.service.d.ts.map +1 -0
  533. package/dist/cli/backend/src/services/v3/escalation-router.service.js +692 -0
  534. package/dist/cli/backend/src/services/v3/escalation-router.service.js.map +1 -0
  535. package/dist/cli/backend/src/services/v3/kr-tracking.service.d.ts +200 -0
  536. package/dist/cli/backend/src/services/v3/kr-tracking.service.d.ts.map +1 -0
  537. package/dist/cli/backend/src/services/v3/kr-tracking.service.js +482 -0
  538. package/dist/cli/backend/src/services/v3/kr-tracking.service.js.map +1 -0
  539. package/dist/cli/backend/src/services/v3/mission-executor.service.d.ts +117 -0
  540. package/dist/cli/backend/src/services/v3/mission-executor.service.d.ts.map +1 -0
  541. package/dist/cli/backend/src/services/v3/mission-executor.service.js +321 -0
  542. package/dist/cli/backend/src/services/v3/mission-executor.service.js.map +1 -0
  543. package/dist/cli/backend/src/services/v3/request-sla.subscriber.d.ts +610 -0
  544. package/dist/cli/backend/src/services/v3/request-sla.subscriber.d.ts.map +1 -0
  545. package/dist/cli/backend/src/services/v3/request-sla.subscriber.js +1529 -0
  546. package/dist/cli/backend/src/services/v3/request-sla.subscriber.js.map +1 -0
  547. package/dist/cli/backend/src/services/v3/request-tracker.service.d.ts +78 -0
  548. package/dist/cli/backend/src/services/v3/request-tracker.service.d.ts.map +1 -0
  549. package/dist/cli/backend/src/services/v3/request-tracker.service.js +108 -0
  550. package/dist/cli/backend/src/services/v3/request-tracker.service.js.map +1 -0
  551. package/dist/cli/backend/src/services/v3/request.service.d.ts +295 -0
  552. package/dist/cli/backend/src/services/v3/request.service.d.ts.map +1 -0
  553. package/dist/cli/backend/src/services/v3/request.service.js +534 -0
  554. package/dist/cli/backend/src/services/v3/request.service.js.map +1 -0
  555. package/dist/cli/backend/src/services/v3/v3-data.service.d.ts +340 -0
  556. package/dist/cli/backend/src/services/v3/v3-data.service.d.ts.map +1 -0
  557. package/dist/cli/backend/src/services/v3/v3-data.service.js +1113 -0
  558. package/dist/cli/backend/src/services/v3/v3-data.service.js.map +1 -0
  559. package/dist/cli/backend/src/types/cross-machine.types.d.ts +103 -0
  560. package/dist/cli/backend/src/types/cross-machine.types.d.ts.map +1 -0
  561. package/dist/cli/backend/src/types/cross-machine.types.js +47 -0
  562. package/dist/cli/backend/src/types/cross-machine.types.js.map +1 -0
  563. package/dist/cli/backend/src/types/intent-task.types.d.ts +402 -0
  564. package/dist/cli/backend/src/types/intent-task.types.d.ts.map +1 -0
  565. package/dist/cli/backend/src/types/intent-task.types.js +403 -0
  566. package/dist/cli/backend/src/types/intent-task.types.js.map +1 -0
  567. package/dist/cli/backend/src/types/orchestrator-state.types.d.ts +531 -0
  568. package/dist/cli/backend/src/types/orchestrator-state.types.d.ts.map +1 -0
  569. package/dist/cli/backend/src/types/orchestrator-state.types.js +110 -0
  570. package/dist/cli/backend/src/types/orchestrator-state.types.js.map +1 -0
  571. package/dist/cli/backend/src/types/v2/index.d.ts +30 -0
  572. package/dist/cli/backend/src/types/v2/index.d.ts.map +1 -0
  573. package/dist/cli/backend/src/types/v2/index.js +22 -0
  574. package/dist/cli/backend/src/types/v2/index.js.map +1 -0
  575. package/dist/cli/backend/src/types/v2/key-result.types.d.ts +279 -0
  576. package/dist/cli/backend/src/types/v2/key-result.types.d.ts.map +1 -0
  577. package/dist/cli/backend/src/types/v2/key-result.types.js +264 -0
  578. package/dist/cli/backend/src/types/v2/key-result.types.js.map +1 -0
  579. package/dist/cli/backend/src/types/v2/mission.types.d.ts +661 -0
  580. package/dist/cli/backend/src/types/v2/mission.types.d.ts.map +1 -0
  581. package/dist/cli/backend/src/types/v2/mission.types.js +713 -0
  582. package/dist/cli/backend/src/types/v2/mission.types.js.map +1 -0
  583. package/dist/cli/backend/src/types/v2/reconcile.types.d.ts +204 -0
  584. package/dist/cli/backend/src/types/v2/reconcile.types.d.ts.map +1 -0
  585. package/dist/cli/backend/src/types/v2/reconcile.types.js +121 -0
  586. package/dist/cli/backend/src/types/v2/reconcile.types.js.map +1 -0
  587. package/dist/cli/backend/src/types/v2/request.types.d.ts +192 -0
  588. package/dist/cli/backend/src/types/v2/request.types.d.ts.map +1 -0
  589. package/dist/cli/backend/src/types/v2/request.types.js +179 -0
  590. package/dist/cli/backend/src/types/v2/request.types.js.map +1 -0
  591. package/dist/cli/backend/src/types/v2/work-item.types.d.ts +181 -1
  592. package/dist/cli/backend/src/types/v2/work-item.types.d.ts.map +1 -1
  593. package/dist/cli/backend/src/types/v2/work-item.types.js +104 -17
  594. package/dist/cli/backend/src/types/v2/work-item.types.js.map +1 -1
  595. package/dist/cli/backend/src/types/v2/workspace.types.d.ts +157 -0
  596. package/dist/cli/backend/src/types/v2/workspace.types.d.ts.map +1 -0
  597. package/dist/cli/backend/src/types/v2/workspace.types.js +173 -0
  598. package/dist/cli/backend/src/types/v2/workspace.types.js.map +1 -0
  599. package/dist/cli/backend/src/utils/async.utils.d.ts +68 -0
  600. package/dist/cli/backend/src/utils/async.utils.d.ts.map +1 -0
  601. package/dist/cli/backend/src/utils/async.utils.js +80 -0
  602. package/dist/cli/backend/src/utils/async.utils.js.map +1 -0
  603. package/dist/cli/backend/src/utils/native-binding.utils.d.ts +128 -0
  604. package/dist/cli/backend/src/utils/native-binding.utils.d.ts.map +1 -0
  605. package/dist/cli/backend/src/utils/native-binding.utils.js +206 -0
  606. package/dist/cli/backend/src/utils/native-binding.utils.js.map +1 -0
  607. package/dist/cli/backend/src/websocket/chat.gateway.d.ts +142 -0
  608. package/dist/cli/backend/src/websocket/chat.gateway.d.ts.map +1 -0
  609. package/dist/cli/backend/src/websocket/chat.gateway.js +327 -0
  610. package/dist/cli/backend/src/websocket/chat.gateway.js.map +1 -0
  611. package/dist/cli/backend/src/websocket/terminal.gateway.d.ts +341 -0
  612. package/dist/cli/backend/src/websocket/terminal.gateway.d.ts.map +1 -0
  613. package/dist/cli/backend/src/websocket/terminal.gateway.js +933 -0
  614. package/dist/cli/backend/src/websocket/terminal.gateway.js.map +1 -0
  615. package/dist/cli/config/vitest-exclude.constants.d.ts +53 -0
  616. package/dist/cli/config/vitest-exclude.constants.d.ts.map +1 -0
  617. package/dist/cli/config/vitest-exclude.constants.js +55 -0
  618. package/dist/cli/config/vitest-exclude.constants.js.map +1 -0
  619. package/package.json +2 -2
  620. package/packages/crewly-agent/src/cli.ts +16 -6
  621. package/packages/crewly-agent/src/runtime/agent-runner.service.test.ts +311 -33
  622. package/packages/crewly-agent/src/runtime/agent-runner.service.ts +221 -12
  623. package/packages/crewly-agent/src/runtime/tool-registry.test.ts +19 -0
  624. package/packages/crewly-agent/src/runtime/tool-registry.ts +4 -1
  625. package/packages/crewly-agent/src/runtime/types.ts +65 -5
@@ -0,0 +1,1331 @@
1
+ import { readFile, access } from 'fs/promises';
2
+ import * as path from 'path';
3
+ import { LoggerService } from '../core/logger.service.js';
4
+ import { MemoryService } from '../memory/memory.service.js';
5
+ import { SOPService } from '../sop/sop.service.js';
6
+ import { getRoleService } from '../settings/role.service.js';
7
+ import { PromptAssemblyService } from './prompt-modules/prompt-assembly.service.js';
8
+ import { getAgentBehaviorLogService } from '../observability/agent-behavior-log.singleton.js';
9
+ /**
10
+ * F14: record a `prompt.size.bytes` telemetry event after the
11
+ * PromptAssemblyService finishes producing a final prompt. Centralised
12
+ * helper called from each `assembler.assemble(...)` callsite so the two
13
+ * paths in this service (team-context vs SessionConfig-only) share the
14
+ * same recording shape.
15
+ *
16
+ * Best-effort — swallows all errors. Never blocks prompt-building.
17
+ *
18
+ * @param prompt - Final assembled prompt string
19
+ * @param sessionName - Session name whose prompt was assembled
20
+ * @param details - Optional extra fields (component breakdown, role, etc.)
21
+ */
22
+ function recordPromptSize(prompt, sessionName, details) {
23
+ try {
24
+ // Byte length per UTF-8 spec — Buffer.byteLength is exact.
25
+ // Falls back to string length for environments without Buffer.
26
+ const bytes = typeof Buffer !== 'undefined'
27
+ ? Buffer.byteLength(prompt, 'utf8')
28
+ : prompt.length;
29
+ getAgentBehaviorLogService()?.record({
30
+ type: 'prompt.size.bytes',
31
+ agent: sessionName || '',
32
+ bytes,
33
+ sessionId: sessionName || undefined,
34
+ details,
35
+ });
36
+ }
37
+ catch {
38
+ /* observability is best-effort */
39
+ }
40
+ }
41
+ // =============================================================================
42
+ // WIRE-1: Autonomy field injection helpers
43
+ // =============================================================================
44
+ /**
45
+ * Derive the organisational role for a member from team-hierarchy facts.
46
+ *
47
+ * Resolution cascade (first match wins):
48
+ * 1. `role === 'orchestrator'` → `'orchestrator'`
49
+ * 2. `canDelegate === true` → `'team-lead'`
50
+ * 3. has subordinates in the team → `'team-lead'`
51
+ * 4. otherwise → `'executor'`
52
+ *
53
+ * This function is total — every member resolves to one of the three roles —
54
+ * so it never throws. Fail-fast on misconfiguration is enforced downstream
55
+ * by {@link RoleBoundaryModule} (a member with `canDelegate=true` whose
56
+ * `orgRole` is undefined when the boundary is rendered indicates the
57
+ * caller bypassed `buildModuleConfigFromTeamMember` — that boundary throws).
58
+ *
59
+ * @param member - Full TeamMember record
60
+ * @param team - Full Team record (used to detect implicit subordination)
61
+ * @returns The resolved organisational role
62
+ */
63
+ export function deriveOrgRole(member, team) {
64
+ if (member.role === 'orchestrator')
65
+ return 'orchestrator';
66
+ if (member.canDelegate === true)
67
+ return 'team-lead';
68
+ if (Array.isArray(member.subordinateIds) && member.subordinateIds.length > 0)
69
+ return 'team-lead';
70
+ // Some legacy team shapes record the relationship on the team side only —
71
+ // catch members who appear as a parent of any other member.
72
+ if (team.members?.some((m) => m.parentMemberId === member.id))
73
+ return 'team-lead';
74
+ return 'executor';
75
+ }
76
+ /**
77
+ * Build a complete {@link ModuleConfig} from a TeamMember + Team pair.
78
+ *
79
+ * Wires every autonomy / organisation / team-context field declared on
80
+ * `TeamMember` and `Team` into the prompt assembler — the gap that caused
81
+ * every TL agent in production to silently render with the executor
82
+ * boundary (because `orgRole` was never injected, and
83
+ * `RoleBoundaryModule.build()` previously fell back to `'executor'`).
84
+ *
85
+ * Fields wired from `member`:
86
+ * - `autonomyLevel`, `domainSOP`, `riskPolicy`, `capabilities`
87
+ * - `jobTitle`, `jobDescription`, `ownershipScope`, `expertId`
88
+ *
89
+ * Fields wired from `team`:
90
+ * - `team.mission` → `teamMission`
91
+ * - `team.budget` → `teamBudget`
92
+ * - `team.qualityGate` → `teamQualityGate`
93
+ * - `team.serviceContract` → `serviceContract`
94
+ * - `team.ownershipScope` → `teamOwnershipScope`
95
+ * - `team.description` → `teamDescription`
96
+ *
97
+ * `orgRole` is resolved via {@link deriveOrgRole}. `canDelegate` is mirrored
98
+ * from the member record. The subordinate list is taken from
99
+ * `runtime.subordinates` when supplied, otherwise resolved from `team.members`.
100
+ *
101
+ * @param member - Full TeamMember record
102
+ * @param team - Full Team record
103
+ * @param runtime - Runtime-host context (session name, project paths, etc.)
104
+ * @returns A fully populated ModuleConfig
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const config = buildModuleConfigFromTeamMember(member, team, {
109
+ * sessionName: 'crewly-product-sam-dd2b46f7',
110
+ * projectPath: '/Users/.../crewly',
111
+ * runtimeType: 'claude-code',
112
+ * agentSkillsPath: path.join(projectRoot, 'config/skills/agent'),
113
+ * tlSkillsPath: path.join(projectRoot, 'config/skills/team-leader'),
114
+ * projectRoot,
115
+ * });
116
+ * const { prompt } = await new PromptAssemblyService().assemble(config);
117
+ * ```
118
+ */
119
+ export function buildModuleConfigFromTeamMember(member, team, runtime) {
120
+ const orgRole = deriveOrgRole(member, team);
121
+ const subordinates = runtime.subordinates ?? resolveSubordinatesFromTeam(member, team);
122
+ return {
123
+ // Identity / runtime
124
+ sessionName: runtime.sessionName,
125
+ memberId: member.id ?? '',
126
+ role: member.role,
127
+ teamId: team.id,
128
+ projectPath: runtime.projectPath,
129
+ runtimeType: runtime.runtimeType,
130
+ // Hierarchy
131
+ canDelegate: member.canDelegate,
132
+ subordinates,
133
+ // Skill paths
134
+ agentSkillsPath: runtime.agentSkillsPath,
135
+ tlSkillsPath: runtime.tlSkillsPath,
136
+ projectRoot: runtime.projectRoot,
137
+ // === Autonomy + capability overlay (member-level) ===
138
+ orgRole,
139
+ autonomyLevel: member.autonomyLevel,
140
+ capabilities: member.capabilities,
141
+ domainSOP: member.domainSOP,
142
+ riskPolicy: member.riskPolicy,
143
+ // === Organisation model (member-level) ===
144
+ jobTitle: member.jobTitle,
145
+ jobDescription: member.jobDescription,
146
+ ownershipScope: member.ownershipScope,
147
+ expertId: member.expertId,
148
+ // === Team-level injection ===
149
+ teamDescription: team.description,
150
+ teamMission: team.mission,
151
+ teamBudget: team.budget,
152
+ teamQualityGate: team.qualityGate,
153
+ serviceContract: team.serviceContract,
154
+ teamOwnershipScope: team.ownershipScope,
155
+ // === Team-graph context (consumed by MissionContextModule) ===
156
+ // Slug derived from team name; matches the convention used elsewhere
157
+ // (e.g. template.controller.toSlug + sessionName composition).
158
+ // Used to resolve `<teamSlug>-team-sub-okr.md` under .crewly/goals/.
159
+ teamSlug: team.name ? toTeamSlug(team.name) : undefined,
160
+ // Single-level parent only — modules that need deeper ancestry
161
+ // should call a graph resolver. Walking the full parent chain
162
+ // here would require runtime team-graph access this builder
163
+ // intentionally does not have.
164
+ teamAncestorIds: team.parentTeamId ? [team.parentTeamId] : undefined,
165
+ };
166
+ }
167
+ /**
168
+ * Convert a team name to a URL-safe slug (lowercase, hyphens, alnum only).
169
+ * Mirrors `toSlug` in `controllers/template/template.controller.ts` so
170
+ * goal / OKR file naming stays consistent across the codebase.
171
+ *
172
+ * @param name - Human-readable team name
173
+ * @returns Lowercase slug suitable for file path segments
174
+ */
175
+ function toTeamSlug(name) {
176
+ return name.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
177
+ }
178
+ /**
179
+ * Resolve a member's subordinate roster from the team record.
180
+ *
181
+ * Used when {@link buildModuleConfigFromTeamMember} is called without a
182
+ * pre-computed `runtime.subordinates`. Maps `member.subordinateIds` to the
183
+ * matching `team.members` entries, dropping any unresolved ids.
184
+ */
185
+ function resolveSubordinatesFromTeam(member, team) {
186
+ if (!Array.isArray(member.subordinateIds) || member.subordinateIds.length === 0)
187
+ return undefined;
188
+ const byId = new Map(team.members?.map((m) => [m.id, m]) ?? []);
189
+ const subs = [];
190
+ for (const subId of member.subordinateIds) {
191
+ const sub = byId.get(subId);
192
+ if (!sub)
193
+ continue;
194
+ subs.push({
195
+ name: sub.name,
196
+ sessionName: sub.sessionName ?? '',
197
+ role: sub.role ?? 'developer',
198
+ memberId: sub.id ?? subId,
199
+ });
200
+ }
201
+ return subs.length > 0 ? subs : undefined;
202
+ }
203
+ /**
204
+ * Service dedicated to building and loading the various prompts used to communicate with agents.
205
+ * Handles prompt templating, variable substitution, and fallback prompt generation.
206
+ */
207
+ export class PromptBuilderService {
208
+ logger;
209
+ projectRoot;
210
+ rolesDirectory;
211
+ /** Absolute path to agent skill scripts (used in prompts so agents can find them from any working directory) */
212
+ agentSkillsPath;
213
+ /** Absolute path to team-leader skill scripts (used in TL addon template variables) */
214
+ tlSkillsPath;
215
+ /**
216
+ * Absolute path to orchestrator-namespaced skill scripts. Per orc-namespace
217
+ * convention (see {@link composePromptWithMemory} role-branched Communication
218
+ * section): orc has its own send-message wrapper that routes through
219
+ * `/terminal/{session}/deliver` (readiness-aware, two-step delivery, retry)
220
+ * instead of the agent-side `/terminal/{session}/write` (raw PTY buffer write,
221
+ * no readiness, no Enter semantics). Spec provenance: 4-piece skill-mistake
222
+ * fix dispatch piece #2 (Sam→Quinn, post-PR #446 merge).
223
+ */
224
+ orchestratorSkillsPath;
225
+ memoryService = null;
226
+ sopService = null;
227
+ constructor(projectRoot = process.cwd()) {
228
+ this.logger = LoggerService.getInstance().createComponentLogger('PromptBuilderService');
229
+ this.projectRoot = projectRoot;
230
+ this.rolesDirectory = path.join(projectRoot, 'config', 'roles');
231
+ this.agentSkillsPath = path.join(projectRoot, 'config', 'skills', 'agent');
232
+ this.tlSkillsPath = path.join(projectRoot, 'config', 'skills', 'team-leader');
233
+ this.orchestratorSkillsPath = path.join(projectRoot, 'config', 'skills', 'orchestrator');
234
+ }
235
+ /**
236
+ * Gets the MemoryService instance (lazy initialization)
237
+ *
238
+ * @returns The MemoryService singleton
239
+ */
240
+ getMemoryService() {
241
+ if (!this.memoryService) {
242
+ this.memoryService = MemoryService.getInstance();
243
+ }
244
+ return this.memoryService;
245
+ }
246
+ /**
247
+ * Gets the SOPService instance (lazy initialization)
248
+ *
249
+ * @returns The SOPService singleton
250
+ */
251
+ getSOPService() {
252
+ if (!this.sopService) {
253
+ this.sopService = SOPService.getInstance();
254
+ }
255
+ return this.sopService;
256
+ }
257
+ /**
258
+ * Build orchestrator prompt for project management
259
+ */
260
+ buildOrchestratorPrompt(projectData) {
261
+ const { projectName, projectPath, teamDetails, requirements } = projectData;
262
+ const teamMembers = Array.isArray(teamDetails.members)
263
+ ? teamDetails.members
264
+ .map((member) => `- ${member.name}: ${member.role} (${member.skills || 'General'})`)
265
+ .join('\n')
266
+ : 'No team members specified';
267
+ const prompt = `I need you to build a full-stack application. The specifications are in ${projectPath}
268
+
269
+ Please:
270
+ 1. Create a ${teamDetails.name || 'development team'} (${teamMembers
271
+ .replace(/- /g, '')
272
+ .replace(/\n/g, ' + ')})
273
+ 2. Have them build according to the specs in ${projectPath}/.crewly/specs/
274
+ 3. Ensure 30-minute git commits
275
+ 4. Coordinate the team to work on Phase 1 simultaneously
276
+
277
+ ## Project: ${projectName}
278
+ **Path**: ${projectPath}
279
+ **Requirements**: ${requirements || 'See project documentation in .crewly/specs/'}
280
+
281
+ ## Team Structure
282
+ ${teamMembers}
283
+
284
+ ## Your Role as Orchestrator
285
+ You are managing the "${projectName}" project. The team sessions have been created for you. Monitor progress, coordinate work between team members, and ensure git commits happen every 30 minutes.
286
+
287
+ The team is ready to start. Begin by reviewing the project specs and coordinating the team to start Phase 1 development.
288
+
289
+ Start all teams on Phase 1 simultaneously.
290
+
291
+ ## Pipeline-First Planning Discipline
292
+
293
+ > Source spec: .crewly/specs/2026-05-05-pipeline-dogfood-prompt-amendment.md §3.1.
294
+
295
+ When you receive a planning-class intent from the owner (or any upstream source), do NOT write a markdown spec or push tasks via send-message as your first move. The pipeline is the planner of record:
296
+
297
+ 1. POST /api/requests first — { sourceConversationItemId, title, description, intentLevel, intentCategory, priority }. Capture the returned id.
298
+ 2. If intentLevel ∈ {L1, L2}, call POST /api/requests/plan with the user message to receive a RequestPlan. Review it; if you accept, materialise WorkItems whose requestId is the new Request.
299
+ 3. Only after the Request exists and at least one WorkItem is in the pool may you send-message a teammate, and that message MUST reference the Request ID — it is a notification of an existing pipeline item, never a substitute for one.
300
+
301
+ Markdown specs in .crewly/specs/ remain valid for durable design artefacts (architecture, post-mortems). They are NOT the channel for "tell the team what to build" — that is the Request. Negative pattern to suppress: "forward to TL via send-message" as the first step after parsing intent.
302
+
303
+ ## Universal Delegator Closure (§3.0 — MANDATORY for every dispatch)
304
+
305
+ > Source spec: .crewly/specs/2026-05-05-pipeline-dogfood-prompt-amendment.md §3.0. Dual of §3.5.
306
+
307
+ Every dispatch (delegate-task, send-message-with-action, materialise WorkItem with target, POST Request handed off to a TL) MUST close the loop with BOTH:
308
+ 1. watch-for-event subscribed to the delegatee (--filter-session, --max-fires N, --max-idle-fires 3)
309
+ 2. schedule-followup fallback at ~2x expected ETA (TL milestone 30-90min → 120min; cross-team 2-8h → 12h)
310
+ 3. cancel-followup BOTH on verified completion (PR merged / Request done / acceptance met).
311
+
312
+ Recursion clause: every delegator hop carries this rule — ORC→TL, TL→Worker, PM→TL, AND Worker→Worker. The pipeline does not exempt any hop. Failure mode it prevents: dispatcher forgets the work it dispatched and only checks status manually hours later because no event ever woke them.`.trim();
313
+ this.logger.debug('Built orchestrator prompt', {
314
+ projectName,
315
+ teamMembersCount: teamDetails.members?.length || 0,
316
+ promptLength: prompt.length,
317
+ });
318
+ return prompt;
319
+ }
320
+ /**
321
+ * Build system prompt for Claude Code agent
322
+ * Loads prompts from config/roles/{role}/prompt.md
323
+ */
324
+ async buildSystemPrompt(config) {
325
+ // Normalize role name to directory name format
326
+ const roleName = config.role.toLowerCase().replace(/\s+/g, '-');
327
+ // Try to load role-specific prompt from config/roles/{role}/prompt.md
328
+ const promptPath = path.resolve(this.rolesDirectory, roleName, 'prompt.md');
329
+ try {
330
+ await access(promptPath);
331
+ let promptContent = await readFile(promptPath, 'utf8');
332
+ // Replace template variables
333
+ promptContent = this.replaceTemplateVariables(promptContent, {
334
+ SESSION_NAME: config.name || 'unknown',
335
+ SESSION_ID: config.name || 'unknown',
336
+ ROLE: config.role,
337
+ PROJECT_PATH: config.projectPath || 'Not specified',
338
+ MEMBER_ID: config.memberId || '',
339
+ AGENT_SKILLS_PATH: this.agentSkillsPath,
340
+ });
341
+ this.logger.info('Loaded role-specific system prompt', {
342
+ role: config.role,
343
+ promptPath,
344
+ promptLength: promptContent.length,
345
+ });
346
+ return promptContent.trim();
347
+ }
348
+ catch (error) {
349
+ // Fallback to generic prompt if specific role prompt not found
350
+ this.logger.warn(`Role-specific prompt not found: ${promptPath}, using fallback`, {
351
+ role: config.role,
352
+ });
353
+ return this.buildFallbackSystemPrompt(config);
354
+ }
355
+ }
356
+ /**
357
+ * Build system prompt with memory and SOP context included.
358
+ *
359
+ * This method builds a complete system prompt that includes:
360
+ * - Base role instructions
361
+ * - Project context
362
+ * - Memory context (agent and project memories)
363
+ * - SOP context (relevant Standard Operating Procedures)
364
+ * - Agent identity information
365
+ *
366
+ * **WIRE-2 migration note:** When a `TeamMember` + `Team` pair is
367
+ * available, prefer {@link buildSystemPromptWithTeamContext} — it
368
+ * routes through {@link buildModuleConfigFromTeamMember} and wires
369
+ * every autonomy / domain-SOP / risk-policy / capability / job-title /
370
+ * ownership-scope / expert-id / team-mission / team-budget /
371
+ * team-quality-gate / service-contract / team-ownership-scope field
372
+ * declared on the TeamMember and Team records. The SessionConfig-only
373
+ * surface here keeps the WIRE-1 stopgap for legacy callers (single-
374
+ * agent flows, tests, and any path that doesn't have team context in
375
+ * scope) so RoleBoundaryModule still resolves correctly for orc + TL
376
+ * agents.
377
+ *
378
+ * @param config - Session configuration (SessionConfig-only)
379
+ * @param options - Prompt building options
380
+ * @returns Complete system prompt with memory and SOPs
381
+ *
382
+ * @example
383
+ * ```typescript
384
+ * const prompt = await promptBuilder.buildSystemPromptWithMemory(config, {
385
+ * includeMemory: true,
386
+ * includeSOPs: true,
387
+ * taskContext: 'implementing authentication',
388
+ * role: 'developer'
389
+ * });
390
+ * ```
391
+ */
392
+ async buildSystemPromptWithMemory(config, options = {}) {
393
+ // Phase 5: Use modular prompt assembly (enabled by default, disable with CREWLY_USE_MODULAR_PROMPTS=false)
394
+ if (process.env.CREWLY_USE_MODULAR_PROMPTS !== 'false') {
395
+ return this.buildModularPrompt(config, options);
396
+ }
397
+ const includeMemory = options.includeMemory !== false;
398
+ const includeSOPs = options.includeSOPs !== false;
399
+ // Get base prompt
400
+ const basePrompt = await this.buildSystemPrompt(config);
401
+ // Build memory context if enabled
402
+ let memoryContext = '';
403
+ if (includeMemory && config.projectPath && config.memberId) {
404
+ memoryContext = await this.buildMemoryContext(config.memberId, config.projectPath, options);
405
+ }
406
+ // Build SOP context if enabled
407
+ let sopContext = '';
408
+ if (includeSOPs) {
409
+ sopContext = await this.buildSOPContext(config.role, options.taskContext, options.taskType, options.sopLimit);
410
+ }
411
+ // Build Team Lead section if applicable (loads tl-addon.md when available)
412
+ const teamLeadContext = await this.buildTeamLeadSection(config);
413
+ // Build Team Norms section (from template norms/*.md)
414
+ const teamNormsContext = await this.buildTeamNormsSection(config.teamId || '', config.role);
415
+ // Compose final prompt with memory, SOPs, TL context, and norms
416
+ if (memoryContext || sopContext || teamLeadContext || teamNormsContext) {
417
+ return this.composePromptWithMemory({
418
+ basePrompt,
419
+ memoryContext,
420
+ sopContext,
421
+ teamLeadContext,
422
+ teamNormsContext,
423
+ sessionName: config.name,
424
+ memberId: config.memberId,
425
+ role: config.role,
426
+ projectPath: config.projectPath,
427
+ teamId: config.teamId,
428
+ runtimeType: config.runtimeType,
429
+ });
430
+ }
431
+ return basePrompt;
432
+ }
433
+ /**
434
+ * Build system prompt with full TeamMember + Team context (WIRE-2).
435
+ *
436
+ * The preferred entrypoint when a `TeamMember` and its enclosing `Team`
437
+ * are both available — wires every autonomy / org / team-level field
438
+ * declared on those records into the prompt assembler via
439
+ * {@link buildModuleConfigFromTeamMember}.
440
+ *
441
+ * This method does NOT mutate the SessionConfig-only stopgap that
442
+ * remains in {@link buildModularPrompt} — that stopgap is still the
443
+ * fallback for legacy callers (single-agent flows, tests, and any path
444
+ * that lacks team context in scope). Once all hot callers migrate to
445
+ * this method, the stopgap becomes truly defensive (only fires for
446
+ * test/legacy paths).
447
+ *
448
+ * @param member - Full TeamMember record
449
+ * @param team - Full Team record
450
+ * @param runtime - Runtime-host context (session name, project paths,
451
+ * pre-resolved subordinates, etc.)
452
+ * @param overlay - Optional overlay applied AFTER the helper builds the
453
+ * ModuleConfig — used for fields that are NOT on TeamMember/Team
454
+ * (e.g. `teamNormsPath`, registration-side `memberId` overrides).
455
+ * @returns The fully-assembled prompt string
456
+ *
457
+ * @example
458
+ * ```typescript
459
+ * const prompt = await promptBuilder.buildSystemPromptWithTeamContext(
460
+ * foundMember,
461
+ * foundTeam,
462
+ * {
463
+ * sessionName,
464
+ * projectPath,
465
+ * runtimeType: 'claude-code',
466
+ * agentSkillsPath: path.join(projectRoot, 'config/skills/agent'),
467
+ * tlSkillsPath: path.join(projectRoot, 'config/skills/team-leader'),
468
+ * projectRoot,
469
+ * },
470
+ * { teamNormsPath: path.join(homedir, '.crewly/teams', team.id, 'norms') },
471
+ * );
472
+ * ```
473
+ */
474
+ async buildSystemPromptWithTeamContext(member, team, runtime, overlay) {
475
+ const baseConfig = buildModuleConfigFromTeamMember(member, team, runtime);
476
+ const moduleConfig = overlay ? { ...baseConfig, ...overlay } : baseConfig;
477
+ const assembler = new PromptAssemblyService();
478
+ const { prompt, report } = await assembler.assemble(moduleConfig);
479
+ // F14 callsite 1/2: prompt.size.bytes (team-context path).
480
+ recordPromptSize(prompt, runtime.sessionName, {
481
+ path: 'team-context',
482
+ role: member.role,
483
+ memberId: member.id,
484
+ teamId: team.id,
485
+ tokens: report.totalTokens,
486
+ moduleCount: report.moduleBreakdown.length,
487
+ });
488
+ this.logger.info('Modular prompt assembled (team-context path)', {
489
+ sessionName: runtime.sessionName,
490
+ memberId: member.id,
491
+ role: member.role,
492
+ teamId: team.id,
493
+ totalTokens: report.totalTokens,
494
+ moduleCount: report.moduleBreakdown.length,
495
+ truncatedCount: report.truncated.length,
496
+ modules: report.moduleBreakdown.map(m => m.name),
497
+ });
498
+ return prompt;
499
+ }
500
+ /**
501
+ * Build system prompt using the modular PromptAssemblyService.
502
+ *
503
+ * Called by default (disable with CREWLY_USE_MODULAR_PROMPTS=false). The modular system handles
504
+ * all prompt sections (identity, skills, communication, recovery, lifecycle,
505
+ * team-reference, memory, soul, learning) with proper token budget enforcement
506
+ * and priority ordering.
507
+ *
508
+ * @param config - Team member session configuration
509
+ * @param options - Prompt options (currently unused by modular system)
510
+ * @returns Assembled prompt string
511
+ */
512
+ async buildModularPrompt(config, _options = {}) {
513
+ const agentSkillsPath = path.join(this.projectRoot, 'config', 'skills', 'agent');
514
+ const tlSkillsPath = path.join(this.projectRoot, 'config', 'skills', 'team-leader');
515
+ // WIRE-2 fallback (post-WIRE-1, post-WIRE-2): callers that provide a
516
+ // SessionConfig WITHOUT a TeamMember + Team pair land here. The new
517
+ // preferred path is {@link buildModuleConfigFromTeamMember} (used by
518
+ // agent-registration.service.ts at the registration callsite); the
519
+ // legacy SessionConfig-only callers retain this stopgap as a
520
+ // defensive default. The cascade resolves orgRole for the two cases
521
+ // that matter when team context is unavailable: orchestrator and TL
522
+ // (via canDelegate=true). Non-TL members keep `undefined` so the
523
+ // executor fallback renders correctly.
524
+ const orgRole = config.role === 'orchestrator'
525
+ ? 'orchestrator'
526
+ : config.canDelegate === true
527
+ ? 'team-lead'
528
+ : undefined;
529
+ const moduleConfig = {
530
+ sessionName: config.name,
531
+ memberId: config.memberId ?? '',
532
+ role: config.role,
533
+ teamId: config.teamId,
534
+ projectPath: config.projectPath,
535
+ runtimeType: config.runtimeType,
536
+ canDelegate: config.canDelegate,
537
+ orgRole,
538
+ subordinates: config.subordinates?.map(s => ({
539
+ name: s.name,
540
+ sessionName: s.sessionName,
541
+ role: s.role,
542
+ memberId: s.memberId,
543
+ })),
544
+ agentSkillsPath,
545
+ tlSkillsPath,
546
+ projectRoot: this.projectRoot,
547
+ };
548
+ const assembler = new PromptAssemblyService();
549
+ const { prompt, report } = await assembler.assemble(moduleConfig);
550
+ // F14 callsite 2/2: prompt.size.bytes (SessionConfig-only path).
551
+ recordPromptSize(prompt, config.name, {
552
+ path: 'session-config',
553
+ role: config.role,
554
+ memberId: config.memberId ?? '',
555
+ teamId: config.teamId ?? '',
556
+ tokens: report.totalTokens,
557
+ moduleCount: report.moduleBreakdown.length,
558
+ });
559
+ this.logger.info('Modular prompt assembled', {
560
+ sessionName: config.name,
561
+ role: config.role,
562
+ totalTokens: report.totalTokens,
563
+ moduleCount: report.moduleBreakdown.length,
564
+ truncatedCount: report.truncated.length,
565
+ modules: report.moduleBreakdown.map(m => m.name),
566
+ });
567
+ return prompt;
568
+ }
569
+ /**
570
+ * Build memory context from agent and project memories
571
+ *
572
+ * @param agentId - Agent identifier
573
+ * @param projectPath - Project path
574
+ * @param options - Prompt options
575
+ * @returns Formatted memory context string
576
+ */
577
+ async buildMemoryContext(agentId, projectPath, options = {}) {
578
+ try {
579
+ const memoryService = this.getMemoryService();
580
+ // Initialize memory for session if needed
581
+ await memoryService.initializeForSession(agentId, options.role || 'developer', projectPath);
582
+ // Get full context from memory service
583
+ const fullContext = await memoryService.getFullContext(agentId, projectPath);
584
+ if (!fullContext || fullContext.trim().length === 0) {
585
+ this.logger.debug('No memory context available', { agentId, projectPath });
586
+ return '';
587
+ }
588
+ this.logger.debug('Built memory context', {
589
+ agentId,
590
+ projectPath,
591
+ contextLength: fullContext.length,
592
+ });
593
+ return `
594
+ ## Your Knowledge Base
595
+
596
+ This is your accumulated knowledge from previous sessions. Use it to work more effectively.
597
+
598
+ ${fullContext}
599
+
600
+ **Note:** You can add new knowledge using the \`remember\` tool and recall specific memories using the \`recall\` tool.
601
+ `.trim();
602
+ }
603
+ catch (error) {
604
+ this.logger.warn('Failed to build memory context', {
605
+ agentId,
606
+ projectPath,
607
+ error: error instanceof Error ? error.message : String(error),
608
+ });
609
+ return '';
610
+ }
611
+ }
612
+ /**
613
+ * Build SOP context from relevant SOPs for the agent's role and task
614
+ *
615
+ * @param role - Agent's role
616
+ * @param taskContext - Current task context for SOP matching
617
+ * @param taskType - Type of task being performed
618
+ * @param limit - Maximum number of SOPs to include
619
+ * @returns Formatted SOP context string
620
+ */
621
+ async buildSOPContext(role, taskContext, taskType, limit) {
622
+ try {
623
+ const sopService = this.getSOPService();
624
+ // Generate SOP context based on role and task
625
+ const sopContext = await sopService.generateSOPContext({
626
+ role: role,
627
+ taskContext: taskContext || '',
628
+ taskType,
629
+ limit,
630
+ });
631
+ if (!sopContext || sopContext.trim().length === 0) {
632
+ this.logger.debug('No SOP context available', { role, taskContext });
633
+ return '';
634
+ }
635
+ this.logger.debug('Built SOP context', {
636
+ role,
637
+ taskContext,
638
+ contextLength: sopContext.length,
639
+ });
640
+ return sopContext;
641
+ }
642
+ catch (error) {
643
+ this.logger.warn('Failed to build SOP context', {
644
+ role,
645
+ taskContext,
646
+ error: error instanceof Error ? error.message : String(error),
647
+ });
648
+ return '';
649
+ }
650
+ }
651
+ /**
652
+ * Build the Team Lead responsibilities section for agents that can delegate.
653
+ *
654
+ * Loads the comprehensive TL management addon from `config/roles/team-leader/tl-addon.md`,
655
+ * resolves template variables (WORKER_LIST, TL_SKILLS_PATH, TEAM_ID, MEMBER_ID, PROJECT_PATH),
656
+ * and returns the formatted section. Falls back to a minimal inline section if the addon
657
+ * file is not found.
658
+ *
659
+ * This enables "auto-stacking": a developer with TL hierarchy gets BOTH their dev role
660
+ * prompt AND full management instructions without changing their role.
661
+ *
662
+ * @param config - Session config with optional TL fields
663
+ * @returns Formatted TL section string, or empty string if not a TL
664
+ */
665
+ async buildTeamLeadSection(config) {
666
+ if (!config.canDelegate || !config.subordinates || config.subordinates.length === 0) {
667
+ return '';
668
+ }
669
+ const workerList = this.buildWorkerList(config.subordinates);
670
+ // Try loading the comprehensive TL addon from file
671
+ const addonPath = path.join(this.rolesDirectory, 'team-leader', 'tl-addon.md');
672
+ try {
673
+ await access(addonPath);
674
+ let addonContent = await readFile(addonPath, 'utf8');
675
+ // Resolve template variables
676
+ addonContent = this.replaceTemplateVariables(addonContent, {
677
+ WORKER_LIST: workerList,
678
+ TL_SKILLS_PATH: this.tlSkillsPath,
679
+ TEAM_ID: config.teamId || '',
680
+ MEMBER_ID: config.memberId || '',
681
+ PROJECT_PATH: config.projectPath || '',
682
+ AGENT_SKILLS_PATH: this.agentSkillsPath,
683
+ // Pipeline Dogfood Amendment §3.5 — TL prompt references {{SESSION_NAME}}
684
+ // in poll-tasks / schedule-followup invocations, so the addon now
685
+ // participates in session-name substitution alongside the worker prompts.
686
+ SESSION_NAME: config.name || 'unknown',
687
+ SESSION_ID: config.name || 'unknown',
688
+ });
689
+ this.logger.info('Loaded TL addon from file', {
690
+ sessionName: config.name,
691
+ subordinateCount: config.subordinates.length,
692
+ addonLength: addonContent.length,
693
+ });
694
+ return addonContent.trim();
695
+ }
696
+ catch {
697
+ // Fallback to minimal inline section if addon file not found
698
+ this.logger.warn('TL addon file not found, using inline fallback', {
699
+ addonPath,
700
+ sessionName: config.name,
701
+ });
702
+ return this.buildInlineTeamLeadSection(config.name, workerList, config.subordinates.length);
703
+ }
704
+ }
705
+ /**
706
+ * Build a formatted worker list string from subordinate info.
707
+ *
708
+ * @param subordinates - Array of subordinate details
709
+ * @returns Formatted markdown list of workers
710
+ */
711
+ buildWorkerList(subordinates) {
712
+ return subordinates
713
+ .map((sub) => `- **${sub.name}** (session: \`${sub.sessionName}\`, memberId: \`${sub.memberId}\`) — ${sub.role}`)
714
+ .join('\n');
715
+ }
716
+ /**
717
+ * Build a minimal inline TL section as fallback when tl-addon.md is not available.
718
+ *
719
+ * @param sessionName - The TL's session name
720
+ * @param workerList - Pre-formatted worker list
721
+ * @param subordinateCount - Number of subordinates
722
+ * @returns Formatted inline TL section
723
+ */
724
+ buildInlineTeamLeadSection(sessionName, workerList, subordinateCount) {
725
+ const section = `## Team Lead Responsibilities
726
+
727
+ You are the **Team Lead** for this team. You manage the following subordinates:
728
+
729
+ ${workerList}
730
+
731
+ ### Your TL Duties
732
+
733
+ 1. **Task Decomposition** — Break down large Sprint-level tasks from the orchestrator into concrete, actionable sub-tasks
734
+ 2. **Delegation** — Assign sub-tasks to subordinates using the \`send-message\` skill. Do NOT do work that a subordinate can handle
735
+ 3. **Quality Review** — Review subordinates' work output before reporting completion upstream
736
+ 4. **Progress Reporting** — Report overall Sprint progress to the orchestrator via \`report-status\`
737
+ 5. **Unblocking** — Help subordinates when they are stuck or need guidance
738
+
739
+ ### Delegation Guidelines
740
+
741
+ - **Delegate by default.** Only do work yourself when it requires TL-level judgment, cross-cutting coordination, or when no subordinate has the right skills.
742
+ - **Be specific.** Each delegated task should have a clear description, acceptance criteria, and priority.
743
+ - **Monitor progress.** Check on delegated tasks periodically using \`send-message\`.
744
+
745
+ ### Task Assignment Template
746
+
747
+ When delegating a task to a subordinate, use this format:
748
+
749
+ \`\`\`
750
+ New task from TL:
751
+
752
+ [TASK] <concise task title>
753
+
754
+ Description: <what needs to be done, including acceptance criteria>
755
+ Priority: <high|normal|low>
756
+ Context: <any relevant background or links to related work>
757
+
758
+ Report back via report-status when done.
759
+ \`\`\``;
760
+ this.logger.info('Built inline Team Lead section (fallback)', {
761
+ sessionName,
762
+ subordinateCount,
763
+ });
764
+ return section;
765
+ }
766
+ /**
767
+ * Build the team norms section for prompt injection.
768
+ *
769
+ * Loads norms from the team's norms directory (copied from template at team creation).
770
+ * Only includes norms whose role list matches the agent's role (or '*' for all).
771
+ *
772
+ * @param teamId - Team ID to load norms for
773
+ * @param role - Agent's role (used to filter norm applicability)
774
+ * @returns Formatted norms markdown, or empty string if no norms found
775
+ */
776
+ async buildTeamNormsSection(teamId, role) {
777
+ if (!teamId)
778
+ return '';
779
+ try {
780
+ const { existsSync: exists, readdirSync, readFileSync } = await import('fs');
781
+ const { join } = await import('path');
782
+ const crewlyHome = join(process.env['HOME'] || '/tmp', '.crewly');
783
+ const normsDir = join(crewlyHome, 'teams', teamId, 'norms');
784
+ if (!exists(normsDir))
785
+ return '';
786
+ // Try to load norms config from team config
787
+ const configPath = join(crewlyHome, 'teams', teamId, 'config.json');
788
+ let normsConfig = [];
789
+ if (exists(configPath)) {
790
+ try {
791
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'));
792
+ normsConfig = config?.norms?.files || [];
793
+ }
794
+ catch {
795
+ // Config parse failed — fall back to loading all .md files
796
+ }
797
+ }
798
+ const sections = [];
799
+ if (normsConfig.length > 0) {
800
+ // Use config-driven loading with role filtering
801
+ for (const norm of normsConfig) {
802
+ const roleMatch = norm.roles.includes('*') || norm.roles.includes(role);
803
+ if (!roleMatch)
804
+ continue;
805
+ const normPath = join(normsDir, norm.file);
806
+ if (!exists(normPath))
807
+ continue;
808
+ const content = readFileSync(normPath, 'utf-8');
809
+ sections.push(content.trim());
810
+ }
811
+ }
812
+ else {
813
+ // Fallback: load all .md files in norms dir
814
+ const files = readdirSync(normsDir).filter(f => f.endsWith('.md')).sort();
815
+ for (const file of files) {
816
+ const content = readFileSync(join(normsDir, file), 'utf-8');
817
+ sections.push(content.trim());
818
+ }
819
+ }
820
+ if (sections.length === 0)
821
+ return '';
822
+ this.logger.info('Built team norms section', { teamId, role, normCount: sections.length });
823
+ return `\n## Team Norms & Standard Operating Procedures\n\nThe following norms are defined by your team template. Follow them strictly.\n\n${sections.join('\n\n---\n\n')}`;
824
+ }
825
+ catch (err) {
826
+ this.logger.warn('Failed to load team norms', {
827
+ teamId,
828
+ error: err instanceof Error ? err.message : String(err),
829
+ });
830
+ return '';
831
+ }
832
+ }
833
+ /**
834
+ * Build the memory routing rules section that tells agents where to store
835
+ * different types of knowledge.
836
+ *
837
+ * - User prefs / team conventions → Crewly `remember` with `scope: project`
838
+ * - Personal work patterns → Crewly `remember` with `scope: agent`
839
+ * - Temporary task notes → project files or Claude native memory
840
+ *
841
+ * @returns Formatted markdown section with memory routing guidance
842
+ */
843
+ buildMemoryRoutingSection() {
844
+ return `## Memory Routing Rules
845
+
846
+ When you learn something worth remembering, store it in the **right place**:
847
+
848
+ | What you learned | Where to store it | How |
849
+ |---|---|---|
850
+ | Team conventions, coding standards, project patterns, shared decisions | Crewly knowledge (project-wide) | \`remember\` with \`scope: "project"\`, \`category: "pattern"\` or \`"decision"\` |
851
+ | User preferences, working style, role-specific tips | Crewly knowledge (agent-specific) | \`remember\` with \`scope: "agent"\`, \`category: "preference"\` or \`"fact"\` |
852
+ | Gotchas, bugs, workarounds discovered during work | Crewly knowledge (project-wide) | \`remember\` with \`scope: "project"\`, \`category: "gotcha"\` |
853
+ | Temporary task notes, in-progress state, scratch data | Project files or Claude native memory | Write to a file in the project, or keep in your conversation context |
854
+
855
+ **Rules of thumb:**
856
+ - If another agent or a future session would benefit → use \`remember\` with \`scope: "project"\`
857
+ - If only YOU would benefit in future sessions → use \`remember\` with \`scope: "agent"\`
858
+ - If it's only useful right now → keep it in your conversation context or a scratch file
859
+ - **Never store secrets, credentials, or tokens** in any memory system`;
860
+ }
861
+ /**
862
+ * Compose a prompt with memory and SOP context included
863
+ *
864
+ * @param parts - Prompt parts to compose
865
+ * @returns Composed prompt string
866
+ */
867
+ composePromptWithMemory(parts) {
868
+ const sections = [];
869
+ // Add base prompt
870
+ sections.push(parts.basePrompt);
871
+ // Add memory context if available
872
+ if (parts.memoryContext && parts.memoryContext.trim()) {
873
+ sections.push('\n---\n');
874
+ sections.push(parts.memoryContext);
875
+ }
876
+ // Add SOP context if available
877
+ if (parts.sopContext && parts.sopContext.trim()) {
878
+ sections.push('\n---\n');
879
+ sections.push(parts.sopContext);
880
+ }
881
+ // Add Team Lead responsibilities if applicable
882
+ if (parts.teamLeadContext && parts.teamLeadContext.trim()) {
883
+ sections.push('\n---\n');
884
+ sections.push(parts.teamLeadContext);
885
+ }
886
+ // Add Team Norms if available
887
+ if (parts.teamNormsContext && parts.teamNormsContext.trim()) {
888
+ sections.push('\n---\n');
889
+ sections.push(parts.teamNormsContext);
890
+ }
891
+ // Add agent identity section
892
+ if (parts.sessionName || parts.memberId || parts.role) {
893
+ sections.push('\n---\n');
894
+ sections.push('## Your Identity');
895
+ if (parts.sessionName)
896
+ sections.push(`- **Session Name:** ${parts.sessionName}`);
897
+ if (parts.memberId)
898
+ sections.push(`- **Member ID:** ${parts.memberId}`);
899
+ if (parts.role)
900
+ sections.push(`- **Role:** ${parts.role}`);
901
+ if (parts.teamId)
902
+ sections.push(`- **Team:** ${parts.teamId}`);
903
+ if (parts.projectPath)
904
+ sections.push(`- **Project Path:** ${parts.projectPath}`);
905
+ }
906
+ // Add memory routing rules
907
+ sections.push('\n---\n');
908
+ sections.push(this.buildMemoryRoutingSection());
909
+ // Add communication instructions — role-branched per orc-namespace convention.
910
+ // Per orc-namespace convention (skill SKILL.md frontmatter excludes orchestrator
911
+ // from assignableRoles on send-message + recall + report-status etc.): orc has
912
+ // its own send-message wrapper at config/skills/orchestrator/send-message/ that
913
+ // routes through /terminal/{session}/deliver (readiness-aware, two-step delivery,
914
+ // retry) instead of the agent-side /terminal/{session}/write (raw PTY buffer
915
+ // write, no readiness, no Enter semantics). Rendering the agent-skills path
916
+ // for orc would let orc fall back to /write and miss orc-specific routing —
917
+ // the exact "ORC was using WRONG send-message skill" gotcha recorded in the
918
+ // project knowledge base on 2026-05-05.
919
+ // See config/skills/agent/core/send-message/SKILL.md for the per-skill rationale.
920
+ // Spec provenance: 4-piece skill-mistake fix dispatch piece #2 (Sam→Quinn,
921
+ // post-PR #446 merge).
922
+ sections.push('\n---\n');
923
+ if (parts.role === 'orchestrator') {
924
+ sections.push(`## Communication (orchestrator-namespaced)
925
+
926
+ You are the orchestrator. Use **orchestrator-namespaced** bash skills at \`${this.orchestratorSkillsPath}/\` for all team communication — they route through the orc-specific message-routing layer (readiness-aware delivery via \`/terminal/{session}/deliver\`, jargon-hygiene gate, owner-vs-agent audience distinction). Read \`~/.crewly/skills/SKILLS_CATALOG.md\` for the full orc-namespaced reference (NOT \`AGENT_SKILLS_CATALOG.md\` — that lists worker-only skills).
927
+
928
+ - \`send-message\` (orc-namespaced wrapper at \`${this.orchestratorSkillsPath}/send-message/execute.sh\`) — readiness-aware delivery to a teammate's terminal session; preferred over the agent-side \`send-message\` at \`${this.agentSkillsPath}/core/send-message/\` which uses raw PTY \`/write\` and lacks orc-specific routing
929
+ - \`record-success\` / \`record-failure\` / \`report-bug\` (orc-namespaced) — orc-side status recording; do NOT use the agent-side \`report-status\` (that is for workers→orc, not orc→self)
930
+ - \`broadcast\` / \`broadcast-to-org\` (orc-namespaced) — multi-agent fan-out
931
+ - \`reply-chat\` / \`reply-slack\` / \`reply-gchat\` / \`reply-remote\` (orc-namespaced) — owner-facing replies on the channel the user wrote on
932
+ - \`schedule-check\` / \`create-cron\` / \`cancel-schedule\` (orc-namespaced) — orc-side scheduling primitives
933
+ - Memory access: orc reads cross-agent memory via the internal service-layer \`recallFromAllAgents()\` rather than the agent-side \`recall\` skill (which is gated to worker roles). Use \`wiki-query\` (v2.1 LLM-wiki; **replaces the retired \`query-knowledge\` skill as of 2026-05-27**) for SOP / runbook / doc lookups. Vault picker: \`~/.crewly/global-wiki\` for cross-team SOPs, team vault for team norms, project vault for project runbooks.
934
+
935
+ **IMPORTANT — namespace gate:** the agent-side skills under \`${this.agentSkillsPath}/core/\` exclude orchestrator from \`assignableRoles\` for a reason. Reaching for them from this orchestrator session bypasses the orc-routing layer:
936
+
937
+ - agent-side \`send-message\` writes raw bytes to a peer's PTY via \`/terminal/{session}/write\` without readiness gating
938
+ - orc-side \`send-message\` uses \`/terminal/{session}/deliver\` with the readiness-aware two-step delivery pattern + retry
939
+
940
+ Always reach for \`${this.orchestratorSkillsPath}/<skill>/\` first.`);
941
+ }
942
+ else {
943
+ sections.push(`## Communication
944
+
945
+ Use bash skills at \`${this.agentSkillsPath}/\` for all team communication. Read \`~/.crewly/skills/AGENT_SKILLS_CATALOG.md\` for a full reference.
946
+ - \`send-message\` to communicate with other agents
947
+ - \`report-progress\` to update on task status
948
+ - \`remember\` to store important learnings (always pass your \`agentId\` and \`projectPath\`)
949
+ - \`recall\` to retrieve relevant knowledge (always pass your \`agentId\` and \`projectPath\`)
950
+ - \`record-learning\` to record learnings (always pass your \`agentId\` and \`projectPath\`)
951
+ - \`get-sops\` to request relevant SOPs for your current situation
952
+
953
+ **IMPORTANT for memory tools:** When calling \`remember\`, \`recall\`, or \`record-learning\`, you MUST pass:
954
+ - \`agentId\`: Your **Session Name** from the Identity section above
955
+ - \`projectPath\`: Your **Project Path** from the Identity section above
956
+ This ensures your knowledge is stored under your identity and in the correct project.
957
+
958
+ **IMPORTANT for recall:** Before answering questions about the project, deployment, architecture, or past decisions, ALWAYS call \`recall\` first to check your stored knowledge.`);
959
+ }
960
+ // Add anti-deliberation instructions for Gemini CLI agents
961
+ if (parts.runtimeType === 'gemini-cli') {
962
+ sections.push('\n---\n');
963
+ sections.push(`## Execution Discipline
964
+
965
+ **IMPORTANT:** Execute tool calls immediately. Do not plan more than 3 tool calls at once.
966
+ Never use phrases like "Wait, I'll also...", "Actually, I'll...", or "Let me also check..." — just execute your tools directly.
967
+ Read files ONE AT A TIME, do not try to batch plan multiple reads.
968
+ If you catch yourself deliberating about what to do next, STOP and execute the most obvious next action immediately.
969
+ Action over deliberation — a wrong tool call is better than no tool call.`);
970
+ }
971
+ // Add language matching instruction
972
+ sections.push('\n---\n');
973
+ sections.push(`## Language Matching
974
+
975
+ **IMPORTANT:** Always reply in the same language the user writes in. If the user sends a message in Chinese, reply in Chinese. If the user writes in English, reply in English. Match the language of each individual message — do not default to English unless the user is writing in English.`);
976
+ return sections.join('\n').trim();
977
+ }
978
+ /**
979
+ * Build the mandatory session recovery protocol section that instructs agents
980
+ * to execute context recovery commands immediately after registration.
981
+ *
982
+ * This section is injected into ALL agent registration prompts (both regular
983
+ * agents and orchestrator) to ensure agents always recover context on startup.
984
+ * The agent will run `recall` and `get-my-context` to load previous knowledge,
985
+ * then report any unfinished work before accepting new tasks.
986
+ *
987
+ * @param sessionName - Agent's session name (used as agentId in skill calls)
988
+ * @param role - Agent's role
989
+ * @param projectPath - Absolute path to the project
990
+ * @returns Formatted markdown section with executable bash commands
991
+ */
992
+ buildSessionRecoverySection(sessionName, role, projectPath) {
993
+ const section = `## Session Recovery Protocol (MANDATORY)
994
+
995
+ **IMMEDIATELY after registering**, you MUST execute the following context recovery steps before saying "Ready" or accepting any tasks. This ensures you recover context from previous sessions and avoid repeating work or missing ongoing tasks.
996
+
997
+ ### Step 1: Recall previous knowledge
998
+ \`\`\`bash
999
+ bash ${this.agentSkillsPath}/core/recall/execute.sh '{"agentId":"${sessionName}","context":"${role} session startup, recent tasks, unfinished work, blockers, key decisions","projectPath":"${projectPath}"}'
1000
+ \`\`\`
1001
+
1002
+ ### Step 1.5: Read your active work (authoritative state)
1003
+ The system has already injected your current Requests + WorkItems above
1004
+ under \`## Your Active Work\` — that section is the source of truth.
1005
+ **State always wins over memory.** If a row carries a \`(memory: ...)\` annotation,
1006
+ the state value is what you should act on; the memory note flags a divergence
1007
+ to investigate, not to override the state.
1008
+
1009
+ Call this skill mid-session if the briefing was truncated (\`... and X more\` marker)
1010
+ or stale (>5 minutes since registration, especially after long-running tasks):
1011
+ \`\`\`bash
1012
+ bash ${this.agentSkillsPath}/core/get-my-active-work/execute.sh --session ${sessionName} --role ${role}
1013
+ \`\`\`
1014
+
1015
+ ### Step 2: Load your full context
1016
+ \`\`\`bash
1017
+ bash ${this.agentSkillsPath}/core/get-my-context/execute.sh '{"agentId":"${sessionName}","agentRole":"${role}","projectPath":"${projectPath}"}'
1018
+ \`\`\`
1019
+
1020
+ ### Step 3: Register yourself as active
1021
+ **CRITICAL:** You MUST call register-self to transition your status from "started" to "active". The system will NOT deliver any messages (Slack, tasks, etc.) to you until you register. Run this BEFORE reporting status:
1022
+ \`\`\`bash
1023
+ bash ${this.agentSkillsPath}/core/register-self/execute.sh '{"sessionName":"${sessionName}","role":"${role}"}'
1024
+ \`\`\`
1025
+
1026
+ ### Step 4: Assess and report
1027
+ After reviewing the results from Steps 1-3:
1028
+ 1. **Check for unfinished work** — If you find tasks that were in progress but not completed, note them
1029
+ 2. **Check for pending blockers** — If previous sessions recorded blockers, note them
1030
+ 3. **Report status** — Include a brief summary of recovered context in your first status message
1031
+
1032
+ **Do NOT skip these steps.** Context recovery prevents duplicate work and ensures continuity across sessions.`;
1033
+ this.logger.debug('Built session recovery section', {
1034
+ sessionName,
1035
+ role,
1036
+ projectPath,
1037
+ sectionLength: section.length,
1038
+ });
1039
+ return section;
1040
+ }
1041
+ /**
1042
+ * Build a continuation prompt for when an agent needs to resume work
1043
+ *
1044
+ * @param agentId - Agent identifier
1045
+ * @param role - Agent's role
1046
+ * @param projectPath - Project path
1047
+ * @param currentTask - Current task being worked on
1048
+ * @param taskContext - Optional task context for SOP matching
1049
+ * @returns Continuation prompt string
1050
+ */
1051
+ async buildContinuationPrompt(agentId, role, projectPath, currentTask, taskContext) {
1052
+ const memoryContext = await this.buildMemoryContext(agentId, projectPath, { role });
1053
+ // Build SOP context based on task description/context
1054
+ const sopContextInput = taskContext || currentTask.description || currentTask.title;
1055
+ const sopContext = await this.buildSOPContext(role, sopContextInput);
1056
+ const sections = ['# Continue Your Work', ''];
1057
+ if (memoryContext) {
1058
+ sections.push(memoryContext);
1059
+ sections.push('');
1060
+ }
1061
+ else {
1062
+ sections.push('(No prior memory context available)');
1063
+ sections.push('');
1064
+ }
1065
+ sections.push(`## Current Task`);
1066
+ sections.push(`**${currentTask.title}**`);
1067
+ if (currentTask.description) {
1068
+ sections.push('');
1069
+ sections.push(currentTask.description);
1070
+ }
1071
+ sections.push('');
1072
+ if (sopContext) {
1073
+ sections.push('---');
1074
+ sections.push('');
1075
+ sections.push(sopContext);
1076
+ sections.push('');
1077
+ }
1078
+ sections.push(`## Instructions`);
1079
+ sections.push('');
1080
+ sections.push('1. Review your progress so far');
1081
+ sections.push('2. Follow the SOPs above for guidance');
1082
+ sections.push('3. Continue working on the task');
1083
+ sections.push('4. Run quality checks before marking complete');
1084
+ sections.push(`5. Run \`bash ${this.agentSkillsPath}/complete-task/execute.sh\` when ALL gates pass`);
1085
+ return sections.join('\n').trim();
1086
+ }
1087
+ /**
1088
+ * Load registration prompt from config files
1089
+ * Loads from config/roles/{role}/prompt.md
1090
+ */
1091
+ async loadRegistrationPrompt(role, sessionName, memberId) {
1092
+ try {
1093
+ // Normalize role name to directory name format
1094
+ const roleName = role.toLowerCase().replace(/\s+/g, '-');
1095
+ const promptPath = path.join(this.rolesDirectory, roleName, 'prompt.md');
1096
+ let prompt = await readFile(promptPath, 'utf8');
1097
+ // Replace template variables
1098
+ const variables = {
1099
+ SESSION_NAME: sessionName,
1100
+ SESSION_ID: sessionName,
1101
+ ROLE: role,
1102
+ AGENT_SKILLS_PATH: this.agentSkillsPath,
1103
+ };
1104
+ if (memberId) {
1105
+ variables.MEMBER_ID = memberId;
1106
+ }
1107
+ prompt = this.replaceTemplateVariables(prompt, variables);
1108
+ // For orchestrator or cases without member ID, remove the memberId parameter
1109
+ if (!memberId) {
1110
+ prompt = prompt.replace(/,\s*"memberId":\s*"\{\{MEMBER_ID\}\}"/g, '');
1111
+ }
1112
+ this.logger.debug('Loaded registration prompt', {
1113
+ role,
1114
+ sessionName,
1115
+ hasMemberId: !!memberId,
1116
+ promptLength: prompt.length,
1117
+ });
1118
+ return prompt;
1119
+ }
1120
+ catch (error) {
1121
+ // Fallback to inline prompt if file doesn't exist
1122
+ this.logger.warn('Could not load registration prompt from config, using fallback', {
1123
+ role,
1124
+ error: error instanceof Error ? error.message : String(error),
1125
+ });
1126
+ const memberIdParam = memberId ? `,"teamMemberId":"${memberId}"` : '';
1127
+ return `# Crewly Agent Registration
1128
+
1129
+ You are running in the **Crewly multi-agent orchestration environment**.
1130
+
1131
+ ## Registration Required
1132
+
1133
+ **IMMEDIATELY** register yourself with the Crewly system using the register-self bash skill:
1134
+
1135
+ \`\`\`bash
1136
+ bash ${this.agentSkillsPath}/register-self/execute.sh '{"role":"${role}","sessionName":"${sessionName}"${memberIdParam}}'
1137
+ \`\`\`
1138
+
1139
+ After registering, read the agent skills catalog for a full reference of available skills:
1140
+ \`\`\`bash
1141
+ cat ~/.crewly/skills/AGENT_SKILLS_CATALOG.md
1142
+ \`\`\`
1143
+
1144
+ **IMPORTANT:** You MUST complete registration before proceeding.
1145
+
1146
+ ## Instructions
1147
+
1148
+ After successful registration, respond with:
1149
+ \`\`\`
1150
+ Agent registered and awaiting instructions from orchestrator.
1151
+ Environment: Crewly
1152
+ Role: ${role}
1153
+ Status: Active and ready for task assignments
1154
+ \`\`\`
1155
+
1156
+ Then wait for explicit task assignments from the orchestrator.`;
1157
+ }
1158
+ }
1159
+ /**
1160
+ * Build a fallback system prompt when role-specific prompt is not found
1161
+ */
1162
+ buildFallbackSystemPrompt(config) {
1163
+ const fallbackPrompt = `Hey! I need your help with ${config.role} tasks on this project.
1164
+
1165
+ ## Quick context about this setup
1166
+
1167
+ This project uses Crewly for team coordination. You have bash skills available at \`${this.agentSkillsPath}/\` that communicate with the Crewly backend running locally. Read the skills catalog at \`~/.crewly/skills/AGENT_SKILLS_CATALOG.md\` for a full reference of available skills.
1168
+
1169
+ ## First thing - please check in
1170
+
1171
+ Please run the register-self skill to let the team dashboard know you're available:
1172
+ \`\`\`bash
1173
+ bash ${this.agentSkillsPath}/register-self/execute.sh '{"role":"${config.role}","sessionName":"${config.name}"}'
1174
+ \`\`\`
1175
+ All it does is update a local status flag so the web UI shows you as online - nothing more.
1176
+
1177
+ ## Default Execution Loop
1178
+
1179
+ When assigned a task, do not wait passively.
1180
+
1181
+ Loop until done, blocked, or explicitly reassigned:
1182
+ 1. Restate the expected outcome in one sentence.
1183
+ 2. Identify the fastest safe path to produce a usable result.
1184
+ 3. Execute immediately.
1185
+ 4. Run cheapest meaningful validation.
1186
+ 5. If validation fails, fix and retry.
1187
+ 6. If blocked by missing goal/outcome/eval, escalate to your TL.
1188
+ 7. If blocked by implementation detail, decide reasonably and continue.
1189
+ 8. Report only when you have a result, blocker, or decision exceeding your authority.
1190
+
1191
+ ## Project context
1192
+ - Session: ${config.name}
1193
+ - Project Path: ${config.projectPath || 'Not specified'}
1194
+ `;
1195
+ this.logger.info('Built fallback system prompt', {
1196
+ role: config.role,
1197
+ promptLength: fallbackPrompt.length,
1198
+ });
1199
+ return fallbackPrompt.trim();
1200
+ }
1201
+ /**
1202
+ * Replace template variables in prompt content
1203
+ */
1204
+ replaceTemplateVariables(content, variables) {
1205
+ let result = content;
1206
+ for (const [key, value] of Object.entries(variables)) {
1207
+ const placeholder = `{{${key}}}`;
1208
+ result = result.replace(new RegExp(placeholder.replace(/[{}]/g, '\\$&'), 'g'), value);
1209
+ }
1210
+ this.logger.debug('Replaced template variables', {
1211
+ variableCount: Object.keys(variables).length,
1212
+ variables: Object.keys(variables),
1213
+ });
1214
+ return result;
1215
+ }
1216
+ /**
1217
+ * Load prompt template from file
1218
+ *
1219
+ * Loads from config/roles/{roleName}/prompt.md or by full file name for backwards compatibility.
1220
+ * Checks for user override files in ~/.crewly/roles/{roleName}/prompt.md first.
1221
+ *
1222
+ * @param fileNameOrRole - Either a role name (e.g., 'orchestrator') or legacy file name (e.g., 'orchestrator-prompt.md')
1223
+ * @returns The prompt content, or null if not found
1224
+ */
1225
+ async loadPromptTemplate(fileNameOrRole) {
1226
+ try {
1227
+ // Try to get role from RoleService
1228
+ const roleService = getRoleService();
1229
+ const roleName = fileNameOrRole.replace(/-prompt\.md$/, '').toLowerCase().replace(/\s+/g, '-');
1230
+ const roleWithPrompt = await roleService.getRoleByName(roleName);
1231
+ if (roleWithPrompt && roleWithPrompt.systemPromptContent) {
1232
+ this.logger.debug('Loaded prompt template from RoleService', {
1233
+ roleName,
1234
+ contentLength: roleWithPrompt.systemPromptContent.length,
1235
+ });
1236
+ return roleWithPrompt.systemPromptContent;
1237
+ }
1238
+ // Fall back to direct file read from roles directory
1239
+ const filePath = path.join(this.rolesDirectory, roleName, 'prompt.md');
1240
+ const content = await readFile(filePath, 'utf8');
1241
+ this.logger.debug('Loaded prompt template', {
1242
+ roleName,
1243
+ contentLength: content.length,
1244
+ source: 'direct-file',
1245
+ });
1246
+ return content;
1247
+ }
1248
+ catch (error) {
1249
+ this.logger.warn('Failed to load prompt template', {
1250
+ fileNameOrRole,
1251
+ error: error instanceof Error ? error.message : String(error),
1252
+ });
1253
+ return null;
1254
+ }
1255
+ }
1256
+ /**
1257
+ * Check if a prompt template exists for a role
1258
+ */
1259
+ async promptTemplateExists(roleName) {
1260
+ try {
1261
+ const normalizedName = roleName.replace(/-prompt\.md$/, '').toLowerCase().replace(/\s+/g, '-');
1262
+ const filePath = path.join(this.rolesDirectory, normalizedName, 'prompt.md');
1263
+ await access(filePath);
1264
+ return true;
1265
+ }
1266
+ catch {
1267
+ return false;
1268
+ }
1269
+ }
1270
+ /**
1271
+ * Get the path to the roles directory
1272
+ */
1273
+ getRolesDirectory() {
1274
+ return this.rolesDirectory;
1275
+ }
1276
+ /**
1277
+ * Build a prompt for project start communication to orchestrator
1278
+ */
1279
+ buildProjectStartPrompt(projectData) {
1280
+ return this.buildOrchestratorPrompt(projectData);
1281
+ }
1282
+ /**
1283
+ * Build a task assignment prompt
1284
+ */
1285
+ buildTaskAssignmentPrompt(task) {
1286
+ const prompt = `
1287
+ ## New Task Assignment
1288
+
1289
+ **Task ID**: ${task.id}
1290
+ **Title**: ${task.title}
1291
+ **Assigned to**: ${task.assigneeRole}
1292
+ **Priority**: ${task.priority.toUpperCase()}
1293
+ ${task.estimatedHours ? `**Estimated Hours**: ${task.estimatedHours}` : ''}
1294
+
1295
+ **Description**:
1296
+ ${task.description}
1297
+
1298
+ Please acknowledge receipt of this task and provide an estimated completion timeline.
1299
+ `;
1300
+ this.logger.debug('Built task assignment prompt', {
1301
+ taskId: task.id,
1302
+ assigneeRole: task.assigneeRole,
1303
+ priority: task.priority,
1304
+ });
1305
+ return prompt.trim();
1306
+ }
1307
+ /**
1308
+ * Build a status update request prompt
1309
+ */
1310
+ buildStatusUpdatePrompt(sessionName, role) {
1311
+ const prompt = `
1312
+ ## Status Update Request
1313
+
1314
+ Please provide a brief status update on your current work:
1315
+
1316
+ 1. **Current Task**: What are you currently working on?
1317
+ 2. **Progress**: What percentage complete is your current task?
1318
+ 3. **Blockers**: Are there any issues preventing progress?
1319
+ 4. **Next Steps**: What will you work on next?
1320
+ 5. **ETA**: When do you expect to complete your current task?
1321
+
1322
+ Keep your response concise and factual.
1323
+ `;
1324
+ this.logger.debug('Built status update prompt', {
1325
+ sessionName,
1326
+ role,
1327
+ });
1328
+ return prompt.trim();
1329
+ }
1330
+ }
1331
+ //# sourceMappingURL=prompt-builder.service.js.map