@amsterdamdatalabs/enact-operator 0.1.2

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 (377) hide show
  1. package/README.md +33 -0
  2. package/dist/index.d.ts +24 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +24 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lanes/autopilot/index.d.ts +95 -0
  7. package/dist/lanes/autopilot/index.d.ts.map +1 -0
  8. package/dist/lanes/autopilot/index.js +499 -0
  9. package/dist/lanes/autopilot/index.js.map +1 -0
  10. package/dist/lanes/ralph/index.d.ts +118 -0
  11. package/dist/lanes/ralph/index.d.ts.map +1 -0
  12. package/dist/lanes/ralph/index.js +680 -0
  13. package/dist/lanes/ralph/index.js.map +1 -0
  14. package/dist/lanes/team/index.d.ts +110 -0
  15. package/dist/lanes/team/index.d.ts.map +1 -0
  16. package/dist/lanes/team/index.js +748 -0
  17. package/dist/lanes/team/index.js.map +1 -0
  18. package/dist/lanes/team/roles.d.ts +15 -0
  19. package/dist/lanes/team/roles.d.ts.map +1 -0
  20. package/dist/lanes/team/roles.js +89 -0
  21. package/dist/lanes/team/roles.js.map +1 -0
  22. package/dist/lanes/ultrawork/burst.d.ts +69 -0
  23. package/dist/lanes/ultrawork/burst.d.ts.map +1 -0
  24. package/dist/lanes/ultrawork/burst.js +254 -0
  25. package/dist/lanes/ultrawork/burst.js.map +1 -0
  26. package/dist/lanes/ultrawork/index.d.ts +159 -0
  27. package/dist/lanes/ultrawork/index.d.ts.map +1 -0
  28. package/dist/lanes/ultrawork/index.js +919 -0
  29. package/dist/lanes/ultrawork/index.js.map +1 -0
  30. package/dist/lanes/ultrawork/phases.d.ts +57 -0
  31. package/dist/lanes/ultrawork/phases.d.ts.map +1 -0
  32. package/dist/lanes/ultrawork/phases.js +116 -0
  33. package/dist/lanes/ultrawork/phases.js.map +1 -0
  34. package/dist/mcp/activation.d.ts +5 -0
  35. package/dist/mcp/activation.d.ts.map +1 -0
  36. package/dist/mcp/activation.js +234 -0
  37. package/dist/mcp/activation.js.map +1 -0
  38. package/dist/mcp/cli.d.ts +11 -0
  39. package/dist/mcp/cli.d.ts.map +1 -0
  40. package/dist/mcp/cli.js +140 -0
  41. package/dist/mcp/cli.js.map +1 -0
  42. package/dist/mcp/continuation.d.ts +5 -0
  43. package/dist/mcp/continuation.d.ts.map +1 -0
  44. package/dist/mcp/continuation.js +360 -0
  45. package/dist/mcp/continuation.js.map +1 -0
  46. package/dist/mcp/jobs.d.ts +5 -0
  47. package/dist/mcp/jobs.d.ts.map +1 -0
  48. package/dist/mcp/jobs.js +212 -0
  49. package/dist/mcp/jobs.js.map +1 -0
  50. package/dist/mcp/laneSupport.d.ts +19 -0
  51. package/dist/mcp/laneSupport.d.ts.map +1 -0
  52. package/dist/mcp/laneSupport.js +21 -0
  53. package/dist/mcp/laneSupport.js.map +1 -0
  54. package/dist/mcp/lanes/autopilot.d.ts +5 -0
  55. package/dist/mcp/lanes/autopilot.d.ts.map +1 -0
  56. package/dist/mcp/lanes/autopilot.js +227 -0
  57. package/dist/mcp/lanes/autopilot.js.map +1 -0
  58. package/dist/mcp/lanes/ralph.d.ts +5 -0
  59. package/dist/mcp/lanes/ralph.d.ts.map +1 -0
  60. package/dist/mcp/lanes/ralph.js +392 -0
  61. package/dist/mcp/lanes/ralph.js.map +1 -0
  62. package/dist/mcp/lanes/team.d.ts +5 -0
  63. package/dist/mcp/lanes/team.d.ts.map +1 -0
  64. package/dist/mcp/lanes/team.js +413 -0
  65. package/dist/mcp/lanes/team.js.map +1 -0
  66. package/dist/mcp/lanes/ultrawork.d.ts +5 -0
  67. package/dist/mcp/lanes/ultrawork.d.ts.map +1 -0
  68. package/dist/mcp/lanes/ultrawork.js +497 -0
  69. package/dist/mcp/lanes/ultrawork.js.map +1 -0
  70. package/dist/mcp/linkage.d.ts +5 -0
  71. package/dist/mcp/linkage.d.ts.map +1 -0
  72. package/dist/mcp/linkage.js +126 -0
  73. package/dist/mcp/linkage.js.map +1 -0
  74. package/dist/mcp/planning.d.ts +5 -0
  75. package/dist/mcp/planning.d.ts.map +1 -0
  76. package/dist/mcp/planning.js +584 -0
  77. package/dist/mcp/planning.js.map +1 -0
  78. package/dist/mcp/rpcTransport.d.ts +17 -0
  79. package/dist/mcp/rpcTransport.d.ts.map +1 -0
  80. package/dist/mcp/rpcTransport.js +90 -0
  81. package/dist/mcp/rpcTransport.js.map +1 -0
  82. package/dist/mcp/schemas/ralphVerify.d.ts +32 -0
  83. package/dist/mcp/schemas/ralphVerify.d.ts.map +1 -0
  84. package/dist/mcp/schemas/ralphVerify.js +20 -0
  85. package/dist/mcp/schemas/ralphVerify.js.map +1 -0
  86. package/dist/mcp/server.d.ts +5 -0
  87. package/dist/mcp/server.d.ts.map +1 -0
  88. package/dist/mcp/server.js +176 -0
  89. package/dist/mcp/server.js.map +1 -0
  90. package/dist/mcp/system.d.ts +5 -0
  91. package/dist/mcp/system.d.ts.map +1 -0
  92. package/dist/mcp/system.js +445 -0
  93. package/dist/mcp/system.js.map +1 -0
  94. package/dist/mcp/toolFilter.d.ts +2 -0
  95. package/dist/mcp/toolFilter.d.ts.map +1 -0
  96. package/dist/mcp/toolFilter.js +2 -0
  97. package/dist/mcp/toolFilter.js.map +1 -0
  98. package/dist/mcp/toolPartitions.d.ts +20 -0
  99. package/dist/mcp/toolPartitions.d.ts.map +1 -0
  100. package/dist/mcp/toolPartitions.js +280 -0
  101. package/dist/mcp/toolPartitions.js.map +1 -0
  102. package/dist/mcp/toolRuntime.d.ts +9 -0
  103. package/dist/mcp/toolRuntime.d.ts.map +1 -0
  104. package/dist/mcp/toolRuntime.js +179 -0
  105. package/dist/mcp/toolRuntime.js.map +1 -0
  106. package/dist/mcp/workflow.d.ts +12 -0
  107. package/dist/mcp/workflow.d.ts.map +1 -0
  108. package/dist/mcp/workflow.js +723 -0
  109. package/dist/mcp/workflow.js.map +1 -0
  110. package/dist/operator/hooks/hookDispatcher.d.ts +39 -0
  111. package/dist/operator/hooks/hookDispatcher.d.ts.map +1 -0
  112. package/dist/operator/hooks/hookDispatcher.js +58 -0
  113. package/dist/operator/hooks/hookDispatcher.js.map +1 -0
  114. package/dist/operator/hooks/hookGating.d.ts +28 -0
  115. package/dist/operator/hooks/hookGating.d.ts.map +1 -0
  116. package/dist/operator/hooks/hookGating.js +61 -0
  117. package/dist/operator/hooks/hookGating.js.map +1 -0
  118. package/dist/operator/hooks/hooks.d.ts +20 -0
  119. package/dist/operator/hooks/hooks.d.ts.map +1 -0
  120. package/dist/operator/hooks/hooks.js +124 -0
  121. package/dist/operator/hooks/hooks.js.map +1 -0
  122. package/dist/operator/hooks/toolGuardHooks.d.ts +86 -0
  123. package/dist/operator/hooks/toolGuardHooks.d.ts.map +1 -0
  124. package/dist/operator/hooks/toolGuardHooks.js +163 -0
  125. package/dist/operator/hooks/toolGuardHooks.js.map +1 -0
  126. package/dist/operator/hud.d.ts +115 -0
  127. package/dist/operator/hud.d.ts.map +1 -0
  128. package/dist/operator/hud.js +229 -0
  129. package/dist/operator/hud.js.map +1 -0
  130. package/dist/operator/missions.d.ts +125 -0
  131. package/dist/operator/missions.d.ts.map +1 -0
  132. package/dist/operator/missions.js +304 -0
  133. package/dist/operator/missions.js.map +1 -0
  134. package/dist/operator/operatorCore.d.ts +11 -0
  135. package/dist/operator/operatorCore.d.ts.map +1 -0
  136. package/dist/operator/operatorCore.js +9 -0
  137. package/dist/operator/operatorCore.js.map +1 -0
  138. package/dist/operator/operatorRuntimeCore.d.ts +17 -0
  139. package/dist/operator/operatorRuntimeCore.d.ts.map +1 -0
  140. package/dist/operator/operatorRuntimeCore.js +17 -0
  141. package/dist/operator/operatorRuntimeCore.js.map +1 -0
  142. package/dist/operator/runtime.d.ts +74 -0
  143. package/dist/operator/runtime.d.ts.map +1 -0
  144. package/dist/operator/runtime.js +357 -0
  145. package/dist/operator/runtime.js.map +1 -0
  146. package/dist/shared/core/bootstrap.d.ts +16 -0
  147. package/dist/shared/core/bootstrap.d.ts.map +1 -0
  148. package/dist/shared/core/bootstrap.js +77 -0
  149. package/dist/shared/core/bootstrap.js.map +1 -0
  150. package/dist/shared/core/contract.d.ts +71 -0
  151. package/dist/shared/core/contract.d.ts.map +1 -0
  152. package/dist/shared/core/contract.js +452 -0
  153. package/dist/shared/core/contract.js.map +1 -0
  154. package/dist/shared/core/events.d.ts +57 -0
  155. package/dist/shared/core/events.d.ts.map +1 -0
  156. package/dist/shared/core/events.js +36 -0
  157. package/dist/shared/core/events.js.map +1 -0
  158. package/dist/shared/core/jobs.d.ts +46 -0
  159. package/dist/shared/core/jobs.d.ts.map +1 -0
  160. package/dist/shared/core/jobs.js +137 -0
  161. package/dist/shared/core/jobs.js.map +1 -0
  162. package/dist/shared/core/json.d.ts +12 -0
  163. package/dist/shared/core/json.d.ts.map +1 -0
  164. package/dist/shared/core/json.js +52 -0
  165. package/dist/shared/core/json.js.map +1 -0
  166. package/dist/shared/core/layoutMigration.d.ts +11 -0
  167. package/dist/shared/core/layoutMigration.d.ts.map +1 -0
  168. package/dist/shared/core/layoutMigration.js +56 -0
  169. package/dist/shared/core/layoutMigration.js.map +1 -0
  170. package/dist/shared/core/lifecycle.d.ts +61 -0
  171. package/dist/shared/core/lifecycle.d.ts.map +1 -0
  172. package/dist/shared/core/lifecycle.js +123 -0
  173. package/dist/shared/core/lifecycle.js.map +1 -0
  174. package/dist/shared/core/packagePaths.d.ts +2 -0
  175. package/dist/shared/core/packagePaths.d.ts.map +1 -0
  176. package/dist/shared/core/packagePaths.js +9 -0
  177. package/dist/shared/core/packagePaths.js.map +1 -0
  178. package/dist/shared/core/terminology.d.ts +38 -0
  179. package/dist/shared/core/terminology.d.ts.map +1 -0
  180. package/dist/shared/core/terminology.js +54 -0
  181. package/dist/shared/core/terminology.js.map +1 -0
  182. package/dist/shared/core/types.d.ts +30 -0
  183. package/dist/shared/core/types.d.ts.map +1 -0
  184. package/dist/shared/core/types.js +2 -0
  185. package/dist/shared/core/types.js.map +1 -0
  186. package/dist/shared/diagnostics/doctor.d.ts +19 -0
  187. package/dist/shared/diagnostics/doctor.d.ts.map +1 -0
  188. package/dist/shared/diagnostics/doctor.js +82 -0
  189. package/dist/shared/diagnostics/doctor.js.map +1 -0
  190. package/dist/shared/diagnostics/hostRollout.d.ts +16 -0
  191. package/dist/shared/diagnostics/hostRollout.d.ts.map +1 -0
  192. package/dist/shared/diagnostics/hostRollout.js +78 -0
  193. package/dist/shared/diagnostics/hostRollout.js.map +1 -0
  194. package/dist/shared/observability/emit.d.ts +3 -0
  195. package/dist/shared/observability/emit.d.ts.map +1 -0
  196. package/dist/shared/observability/emit.js +17 -0
  197. package/dist/shared/observability/emit.js.map +1 -0
  198. package/dist/shared/observability/testWorkspace.d.ts +4 -0
  199. package/dist/shared/observability/testWorkspace.d.ts.map +1 -0
  200. package/dist/shared/observability/testWorkspace.js +35 -0
  201. package/dist/shared/observability/testWorkspace.js.map +1 -0
  202. package/dist/shared/state/installRegistry.d.ts +22 -0
  203. package/dist/shared/state/installRegistry.d.ts.map +1 -0
  204. package/dist/shared/state/installRegistry.js +51 -0
  205. package/dist/shared/state/installRegistry.js.map +1 -0
  206. package/dist/shared/state/session.d.ts +18 -0
  207. package/dist/shared/state/session.d.ts.map +1 -0
  208. package/dist/shared/state/session.js +127 -0
  209. package/dist/shared/state/session.js.map +1 -0
  210. package/dist/shared/state/state.d.ts +16 -0
  211. package/dist/shared/state/state.d.ts.map +1 -0
  212. package/dist/shared/state/state.js +91 -0
  213. package/dist/shared/state/state.js.map +1 -0
  214. package/dist/shared/state/tasks.d.ts +113 -0
  215. package/dist/shared/state/tasks.d.ts.map +1 -0
  216. package/dist/shared/state/tasks.js +274 -0
  217. package/dist/shared/state/tasks.js.map +1 -0
  218. package/dist/shared/workflow/activation/activeSkill.d.ts +46 -0
  219. package/dist/shared/workflow/activation/activeSkill.d.ts.map +1 -0
  220. package/dist/shared/workflow/activation/activeSkill.js +158 -0
  221. package/dist/shared/workflow/activation/activeSkill.js.map +1 -0
  222. package/dist/shared/workflow/activation/gateProfiles.d.ts +26 -0
  223. package/dist/shared/workflow/activation/gateProfiles.d.ts.map +1 -0
  224. package/dist/shared/workflow/activation/gateProfiles.js +102 -0
  225. package/dist/shared/workflow/activation/gateProfiles.js.map +1 -0
  226. package/dist/shared/workflow/activation/modeMatrix.d.ts +28 -0
  227. package/dist/shared/workflow/activation/modeMatrix.d.ts.map +1 -0
  228. package/dist/shared/workflow/activation/modeMatrix.js +91 -0
  229. package/dist/shared/workflow/activation/modeMatrix.js.map +1 -0
  230. package/dist/shared/workflow/activation/skillActivation.d.ts +74 -0
  231. package/dist/shared/workflow/activation/skillActivation.d.ts.map +1 -0
  232. package/dist/shared/workflow/activation/skillActivation.js +485 -0
  233. package/dist/shared/workflow/activation/skillActivation.js.map +1 -0
  234. package/dist/shared/workflow/activation/skillVariant.d.ts +18 -0
  235. package/dist/shared/workflow/activation/skillVariant.d.ts.map +1 -0
  236. package/dist/shared/workflow/activation/skillVariant.js +44 -0
  237. package/dist/shared/workflow/activation/skillVariant.js.map +1 -0
  238. package/dist/shared/workflow/authority/authority.d.ts +34 -0
  239. package/dist/shared/workflow/authority/authority.d.ts.map +1 -0
  240. package/dist/shared/workflow/authority/authority.js +64 -0
  241. package/dist/shared/workflow/authority/authority.js.map +1 -0
  242. package/dist/shared/workflow/closure/closureManifest.d.ts +39 -0
  243. package/dist/shared/workflow/closure/closureManifest.d.ts.map +1 -0
  244. package/dist/shared/workflow/closure/closureManifest.js +62 -0
  245. package/dist/shared/workflow/closure/closureManifest.js.map +1 -0
  246. package/dist/shared/workflow/closure/closureRequirements.d.ts +12 -0
  247. package/dist/shared/workflow/closure/closureRequirements.d.ts.map +1 -0
  248. package/dist/shared/workflow/closure/closureRequirements.js +30 -0
  249. package/dist/shared/workflow/closure/closureRequirements.js.map +1 -0
  250. package/dist/shared/workflow/closure/contractParity.d.ts +24 -0
  251. package/dist/shared/workflow/closure/contractParity.d.ts.map +1 -0
  252. package/dist/shared/workflow/closure/contractParity.js +238 -0
  253. package/dist/shared/workflow/closure/contractParity.js.map +1 -0
  254. package/dist/shared/workflow/closure/contractParityContext.d.ts +8 -0
  255. package/dist/shared/workflow/closure/contractParityContext.d.ts.map +1 -0
  256. package/dist/shared/workflow/closure/contractParityContext.js +50 -0
  257. package/dist/shared/workflow/closure/contractParityContext.js.map +1 -0
  258. package/dist/shared/workflow/closure/scopeGuard.d.ts +11 -0
  259. package/dist/shared/workflow/closure/scopeGuard.d.ts.map +1 -0
  260. package/dist/shared/workflow/closure/scopeGuard.js +69 -0
  261. package/dist/shared/workflow/closure/scopeGuard.js.map +1 -0
  262. package/dist/shared/workflow/closure/ultragoalArtifact.d.ts +13 -0
  263. package/dist/shared/workflow/closure/ultragoalArtifact.d.ts.map +1 -0
  264. package/dist/shared/workflow/closure/ultragoalArtifact.js +31 -0
  265. package/dist/shared/workflow/closure/ultragoalArtifact.js.map +1 -0
  266. package/dist/shared/workflow/closure/workflowReconcile.d.ts +70 -0
  267. package/dist/shared/workflow/closure/workflowReconcile.d.ts.map +1 -0
  268. package/dist/shared/workflow/closure/workflowReconcile.js +267 -0
  269. package/dist/shared/workflow/closure/workflowReconcile.js.map +1 -0
  270. package/dist/shared/workflow/continuation/continuation.d.ts +109 -0
  271. package/dist/shared/workflow/continuation/continuation.d.ts.map +1 -0
  272. package/dist/shared/workflow/continuation/continuation.js +550 -0
  273. package/dist/shared/workflow/continuation/continuation.js.map +1 -0
  274. package/dist/shared/workflow/continuation/continuationEventReservations.d.ts +17 -0
  275. package/dist/shared/workflow/continuation/continuationEventReservations.d.ts.map +1 -0
  276. package/dist/shared/workflow/continuation/continuationEventReservations.js +88 -0
  277. package/dist/shared/workflow/continuation/continuationEventReservations.js.map +1 -0
  278. package/dist/shared/workflow/continuation/continuationFollowUp.d.ts +114 -0
  279. package/dist/shared/workflow/continuation/continuationFollowUp.d.ts.map +1 -0
  280. package/dist/shared/workflow/continuation/continuationFollowUp.js +330 -0
  281. package/dist/shared/workflow/continuation/continuationFollowUp.js.map +1 -0
  282. package/dist/shared/workflow/continuation/continuationOrchestrator.d.ts +66 -0
  283. package/dist/shared/workflow/continuation/continuationOrchestrator.d.ts.map +1 -0
  284. package/dist/shared/workflow/continuation/continuationOrchestrator.js +144 -0
  285. package/dist/shared/workflow/continuation/continuationOrchestrator.js.map +1 -0
  286. package/dist/shared/workflow/continuation/hookContinuation.d.ts +44 -0
  287. package/dist/shared/workflow/continuation/hookContinuation.d.ts.map +1 -0
  288. package/dist/shared/workflow/continuation/hookContinuation.js +85 -0
  289. package/dist/shared/workflow/continuation/hookContinuation.js.map +1 -0
  290. package/dist/shared/workflow/continuation/stopPolicy.d.ts +38 -0
  291. package/dist/shared/workflow/continuation/stopPolicy.d.ts.map +1 -0
  292. package/dist/shared/workflow/continuation/stopPolicy.js +435 -0
  293. package/dist/shared/workflow/continuation/stopPolicy.js.map +1 -0
  294. package/dist/shared/workflow/continuation/stopVerdict.d.ts +31 -0
  295. package/dist/shared/workflow/continuation/stopVerdict.d.ts.map +1 -0
  296. package/dist/shared/workflow/continuation/stopVerdict.js +98 -0
  297. package/dist/shared/workflow/continuation/stopVerdict.js.map +1 -0
  298. package/dist/shared/workflow/delegation/delegatedSession.d.ts +118 -0
  299. package/dist/shared/workflow/delegation/delegatedSession.d.ts.map +1 -0
  300. package/dist/shared/workflow/delegation/delegatedSession.js +496 -0
  301. package/dist/shared/workflow/delegation/delegatedSession.js.map +1 -0
  302. package/dist/shared/workflow/delegation/delegationPrompt.d.ts +3 -0
  303. package/dist/shared/workflow/delegation/delegationPrompt.d.ts.map +1 -0
  304. package/dist/shared/workflow/delegation/delegationPrompt.js +15 -0
  305. package/dist/shared/workflow/delegation/delegationPrompt.js.map +1 -0
  306. package/dist/shared/workflow/delegation/sessionTasks.d.ts +40 -0
  307. package/dist/shared/workflow/delegation/sessionTasks.d.ts.map +1 -0
  308. package/dist/shared/workflow/delegation/sessionTasks.js +73 -0
  309. package/dist/shared/workflow/delegation/sessionTasks.js.map +1 -0
  310. package/dist/shared/workflow/delegation/subagentRuntime.d.ts +26 -0
  311. package/dist/shared/workflow/delegation/subagentRuntime.d.ts.map +1 -0
  312. package/dist/shared/workflow/delegation/subagentRuntime.js +231 -0
  313. package/dist/shared/workflow/delegation/subagentRuntime.js.map +1 -0
  314. package/dist/shared/workflow/delivery/adoAuxiliaryRuntime.d.ts +79 -0
  315. package/dist/shared/workflow/delivery/adoAuxiliaryRuntime.d.ts.map +1 -0
  316. package/dist/shared/workflow/delivery/adoAuxiliaryRuntime.js +166 -0
  317. package/dist/shared/workflow/delivery/adoAuxiliaryRuntime.js.map +1 -0
  318. package/dist/shared/workflow/delivery/finalWave.d.ts +57 -0
  319. package/dist/shared/workflow/delivery/finalWave.d.ts.map +1 -0
  320. package/dist/shared/workflow/delivery/finalWave.js +123 -0
  321. package/dist/shared/workflow/delivery/finalWave.js.map +1 -0
  322. package/dist/shared/workflow/delivery/lifecyclePushMap.d.ts +68 -0
  323. package/dist/shared/workflow/delivery/lifecyclePushMap.d.ts.map +1 -0
  324. package/dist/shared/workflow/delivery/lifecyclePushMap.js +82 -0
  325. package/dist/shared/workflow/delivery/lifecyclePushMap.js.map +1 -0
  326. package/dist/shared/workflow/delivery/prSidecar.d.ts +7 -0
  327. package/dist/shared/workflow/delivery/prSidecar.d.ts.map +1 -0
  328. package/dist/shared/workflow/delivery/prSidecar.js +4 -0
  329. package/dist/shared/workflow/delivery/prSidecar.js.map +1 -0
  330. package/dist/shared/workflow/delivery/reviewStaleness.d.ts +37 -0
  331. package/dist/shared/workflow/delivery/reviewStaleness.d.ts.map +1 -0
  332. package/dist/shared/workflow/delivery/reviewStaleness.js +94 -0
  333. package/dist/shared/workflow/delivery/reviewStaleness.js.map +1 -0
  334. package/dist/shared/workflow/planning/hyperplan.d.ts +40 -0
  335. package/dist/shared/workflow/planning/hyperplan.d.ts.map +1 -0
  336. package/dist/shared/workflow/planning/hyperplan.js +133 -0
  337. package/dist/shared/workflow/planning/hyperplan.js.map +1 -0
  338. package/dist/shared/workflow/planning/notepad.d.ts +17 -0
  339. package/dist/shared/workflow/planning/notepad.d.ts.map +1 -0
  340. package/dist/shared/workflow/planning/notepad.js +84 -0
  341. package/dist/shared/workflow/planning/notepad.js.map +1 -0
  342. package/dist/shared/workflow/planning/planFormat.d.ts +3 -0
  343. package/dist/shared/workflow/planning/planFormat.d.ts.map +1 -0
  344. package/dist/shared/workflow/planning/planFormat.js +14 -0
  345. package/dist/shared/workflow/planning/planFormat.js.map +1 -0
  346. package/package.json +155 -0
  347. package/runtime/hooks/_continuation.mjs +2 -0
  348. package/runtime/hooks/_lib.mjs +2 -0
  349. package/runtime/hooks/_toolGuards.mjs +2 -0
  350. package/runtime/hooks/lanes/resolveSkillActivation.mjs +241 -0
  351. package/runtime/hooks/lanes/user-prompt-submit.mjs +326 -0
  352. package/runtime/hooks/layout-dir.mjs +2 -0
  353. package/runtime/hooks/lifecycle/pre-compact.mjs +121 -0
  354. package/runtime/hooks/lifecycle/session-start.mjs +356 -0
  355. package/runtime/hooks/lifecycle/stop.mjs +223 -0
  356. package/runtime/hooks/observability.mjs +2 -0
  357. package/runtime/hooks/post-tool-use-failure.mjs +5 -0
  358. package/runtime/hooks/post-tool-use.mjs +4 -0
  359. package/runtime/hooks/pre-compact.mjs +4 -0
  360. package/runtime/hooks/pre-tool-use.mjs +4 -0
  361. package/runtime/hooks/resolveSkillActivation.mjs +4 -0
  362. package/runtime/hooks/root-dir.mjs +2 -0
  363. package/runtime/hooks/session-start.mjs +4 -0
  364. package/runtime/hooks/shared/_continuation.mjs +341 -0
  365. package/runtime/hooks/shared/_lib.mjs +60 -0
  366. package/runtime/hooks/shared/_toolGuards.mjs +237 -0
  367. package/runtime/hooks/shared/config.mjs +143 -0
  368. package/runtime/hooks/shared/layout-dir.mjs +12 -0
  369. package/runtime/hooks/shared/observability.mjs +257 -0
  370. package/runtime/hooks/shared/root-dir.mjs +9 -0
  371. package/runtime/hooks/stop.mjs +4 -0
  372. package/runtime/hooks/subagent-tracker.mjs +4 -0
  373. package/runtime/hooks/subagents/subagent-tracker.mjs +106 -0
  374. package/runtime/hooks/tools/post-tool-use-failure.mjs +251 -0
  375. package/runtime/hooks/tools/post-tool-use.mjs +205 -0
  376. package/runtime/hooks/tools/pre-tool-use.mjs +268 -0
  377. package/runtime/hooks/user-prompt-submit.mjs +4 -0
@@ -0,0 +1,241 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs';
3
+ import { startAutopilot, retargetAutopilot } from '@amsterdamdatalabs/enact-operator/autopilot';
4
+ import { activateActiveSkill } from '@amsterdamdatalabs/enact-operator/activeSkill';
5
+ import { startRalph, retargetRalph } from '@amsterdamdatalabs/enact-operator/ralph';
6
+ import { createTeam } from '@amsterdamdatalabs/enact-operator/team';
7
+ import { startUltrawork, retargetUltrawork } from '@amsterdamdatalabs/enact-operator/ultrawork';
8
+ import {
9
+ executeActivation,
10
+ listKnownSkills,
11
+ parseSkillActivation,
12
+ recordActivation,
13
+ } from '@amsterdamdatalabs/enact-operator/skillActivation';
14
+
15
+ const ACTIVE_SKILL_LANES = new Set(['autopilot', 'ralph', 'ralplan', 'team', 'ultrawork', 'ultragoal', 'ultraqa']);
16
+
17
+ function parseInput() {
18
+ try {
19
+ const raw = readFileSync(0, 'utf8');
20
+ if (!raw) {
21
+ return null;
22
+ }
23
+ const parsed = JSON.parse(raw);
24
+ if (typeof parsed.root !== 'string' || typeof parsed.prompt !== 'string') {
25
+ return null;
26
+ }
27
+ return parsed;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+
33
+ function applyActivation(root, result) {
34
+ if (!result.requiredAction) {
35
+ return result;
36
+ }
37
+
38
+ const { tool } = result.requiredAction;
39
+ const params = result.requiredAction.params ?? {};
40
+
41
+ if (tool === 'operator_ralph_start' || tool === 'operator_ralph_start') {
42
+ const started = startRalph(root, {
43
+ goal: String(params.goal),
44
+ goalScope: typeof params.goalScope === 'string' ? params.goalScope : undefined,
45
+ gateProfile: typeof params.gateProfile === 'string' ? params.gateProfile : undefined,
46
+ linkedUltraworkId: typeof params.linkedUltraworkId === 'string' ? params.linkedUltraworkId : undefined,
47
+ activationMetadata: params.activationMetadata,
48
+ });
49
+ return { ...result, startedStateId: started.id };
50
+ }
51
+
52
+ if (tool === 'operator_team_init' || tool === 'operator_team_init') {
53
+ const teamOptions =
54
+ typeof params.initialTaskTitle === 'string' || typeof params.initialOwner === 'string'
55
+ ? {
56
+ initialTaskTitle:
57
+ typeof params.initialTaskTitle === 'string' ? params.initialTaskTitle : undefined,
58
+ initialOwner: typeof params.initialOwner === 'string' ? params.initialOwner : undefined,
59
+ }
60
+ : undefined;
61
+ const started = createTeam(
62
+ root,
63
+ String(params.name),
64
+ Array.isArray(params.executors) ? params.executors : [
65
+ { id: 'executor', role: 'executor' },
66
+ { id: 'reviewer', role: 'reviewer' },
67
+ { id: 'tester', role: 'tester' },
68
+ { id: 'documenter', role: 'documenter' },
69
+ ],
70
+ typeof params.baseBranch === 'string' ? params.baseBranch : 'main',
71
+ teamOptions,
72
+ );
73
+ return { ...result, startedStateId: started.id };
74
+ }
75
+
76
+ if (tool === 'operator_autopilot_start' || tool === 'operator_autopilot_start') {
77
+ const started = startAutopilot(root, {
78
+ intent: String(params.intent),
79
+ goalScope: typeof params.goalScope === 'string' ? params.goalScope : undefined,
80
+ gateProfile: typeof params.gateProfile === 'string' ? params.gateProfile : undefined,
81
+ activationMetadata: params.activationMetadata,
82
+ });
83
+ return { ...result, startedStateId: started.id };
84
+ }
85
+
86
+ if (tool === 'operator_ultrawork_start' || tool === 'operator_ultrawork_start') {
87
+ const started = startUltrawork(root, {
88
+ intent: String(params.intent),
89
+ goalScope: typeof params.goalScope === 'string' ? params.goalScope : undefined,
90
+ gateProfile: typeof params.gateProfile === 'string' ? params.gateProfile : undefined,
91
+ activationMetadata: params.activationMetadata,
92
+ });
93
+ return { ...result, startedStateId: started.id };
94
+ }
95
+
96
+ if (tool === 'operator_autopilot_retarget' || tool === 'operator_autopilot_retarget') {
97
+ retargetAutopilot(root, {
98
+ intent: String(params.intent),
99
+ mode: params.mode,
100
+ goalScope: typeof params.goalScope === 'string' ? params.goalScope : undefined,
101
+ gateProfile: typeof params.gateProfile === 'string' ? params.gateProfile : undefined,
102
+ note: typeof params.note === 'string' ? params.note : undefined,
103
+ by: typeof params.by === 'string' ? params.by : undefined,
104
+ });
105
+ return result;
106
+ }
107
+
108
+ if (tool === 'operator_ralph_retarget' || tool === 'operator_ralph_retarget') {
109
+ retargetRalph(root, {
110
+ goal: String(params.goal),
111
+ mode: params.mode,
112
+ goalScope: typeof params.goalScope === 'string' ? params.goalScope : undefined,
113
+ gateProfile: typeof params.gateProfile === 'string' ? params.gateProfile : undefined,
114
+ linkedUltraworkId: typeof params.linkedUltraworkId === 'string' ? params.linkedUltraworkId : undefined,
115
+ note: typeof params.note === 'string' ? params.note : undefined,
116
+ by: typeof params.by === 'string' ? params.by : undefined,
117
+ });
118
+ return result;
119
+ }
120
+
121
+ if (tool === 'operator_ultrawork_retarget' || tool === 'operator_ultrawork_retarget') {
122
+ retargetUltrawork(root, {
123
+ intent: String(params.intent),
124
+ mode: params.mode,
125
+ goalScope: typeof params.goalScope === 'string' ? params.goalScope : undefined,
126
+ gateProfile: typeof params.gateProfile === 'string' ? params.gateProfile : undefined,
127
+ note: typeof params.note === 'string' ? params.note : undefined,
128
+ by: typeof params.by === 'string' ? params.by : undefined,
129
+ });
130
+ return result;
131
+ }
132
+
133
+ throw new Error(`Unsupported activation action tool "${tool}".`);
134
+ }
135
+
136
+ function normalizeKnownSkills(request) {
137
+ if (Array.isArray(request.knownSkills) && request.knownSkills.length > 0) {
138
+ return request.knownSkills;
139
+ }
140
+ return listKnownSkills(request.root);
141
+ }
142
+
143
+ function laneMetadata(skill) {
144
+ return { lane: ACTIVE_SKILL_LANES.has(skill) };
145
+ }
146
+
147
+ function extractModelIdentity(req) {
148
+ const explicit =
149
+ typeof req.modelId === 'string' ? req.modelId :
150
+ typeof req.model_id === 'string' ? req.model_id :
151
+ typeof req.model === 'string' ? req.model :
152
+ null;
153
+ if (explicit && explicit.trim()) {
154
+ return explicit.trim();
155
+ }
156
+ const headers = req.headers;
157
+ if (headers && typeof headers === 'object') {
158
+ const value =
159
+ headers['X-Model-Identity'] ??
160
+ headers['x-model-identity'] ??
161
+ headers['x_model_identity'];
162
+ if (typeof value === 'string' && value.trim()) {
163
+ return value.trim();
164
+ }
165
+ }
166
+ return undefined;
167
+ }
168
+
169
+ function enrichVariantSelection(req, result) {
170
+ const skill = result?.intent?.skill;
171
+ if (typeof skill !== 'string') {
172
+ return result;
173
+ }
174
+ const modelIdentity = extractModelIdentity(req);
175
+ if (result.requiredAction?.params?.activationMetadata && typeof result.requiredAction.params.activationMetadata === 'object') {
176
+ result.requiredAction.params.activationMetadata = {
177
+ ...result.requiredAction.params.activationMetadata,
178
+ modelIdentity,
179
+ };
180
+ }
181
+ return {
182
+ ...result,
183
+ modelIdentity,
184
+ };
185
+ }
186
+
187
+ function syncActiveSkill(root, skill) {
188
+ if (!ACTIVE_SKILL_LANES.has(skill)) {
189
+ return;
190
+ }
191
+ if (!laneMetadata(skill).lane) {
192
+ return;
193
+ }
194
+ activateActiveSkill(root, skill, 'resolveSkillActivation');
195
+ }
196
+
197
+ function main() {
198
+ const request = parseInput();
199
+ if (!request) {
200
+ process.stdout.write('null');
201
+ return;
202
+ }
203
+
204
+ const knownSkills = normalizeKnownSkills(request);
205
+ const intent = parseSkillActivation(request.prompt, 'hook', knownSkills);
206
+ if (!intent) {
207
+ process.stdout.write('null');
208
+ return;
209
+ }
210
+
211
+ const result = enrichVariantSelection(request, executeActivation(request.root, intent));
212
+ if (request.dryRun || result.activated || result.requiredAction === null) {
213
+ if (!request.dryRun) {
214
+ if (result.activated) {
215
+ syncActiveSkill(request.root, result.intent.skill);
216
+ }
217
+ recordActivation(request.root, result);
218
+ }
219
+ process.stdout.write(JSON.stringify(result));
220
+ return;
221
+ }
222
+
223
+ try {
224
+ const next = applyActivation(request.root, result);
225
+ if (next.startedStateId) {
226
+ syncActiveSkill(request.root, next.intent.skill);
227
+ }
228
+ recordActivation(request.root, next);
229
+ process.stdout.write(JSON.stringify(next));
230
+ } catch (error) {
231
+ const failure = {
232
+ ...result,
233
+ activated: false,
234
+ error: error instanceof Error ? error.message : String(error),
235
+ };
236
+ recordActivation(request.root, failure);
237
+ process.stdout.write(JSON.stringify(failure));
238
+ }
239
+ }
240
+
241
+ main();
@@ -0,0 +1,326 @@
1
+ #!/usr/bin/env node
2
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { execFileSync } from "node:child_process";
5
+ import { fileURLToPath } from "node:url";
6
+ import { emitHookFired, registerHookFailureTrap } from "../shared/observability.mjs";
7
+ import { readMergedOperatorConfig } from "../shared/config.mjs";
8
+ import { rootDirFrom } from "../shared/root-dir.mjs";
9
+ import { layoutDir, layoutPath } from "../shared/layout-dir.mjs";
10
+ import { readHooksVerbose, verboseLog } from "../shared/_lib.mjs";
11
+
12
+ function readStdin() {
13
+ try {
14
+ return JSON.parse(readFileSync(0, "utf8") || "{}");
15
+ } catch {
16
+ return {};
17
+ }
18
+ }
19
+
20
+ function readJson(path, fallback) {
21
+ try {
22
+ return JSON.parse(readFileSync(path, "utf8"));
23
+ } catch {
24
+ return fallback;
25
+ }
26
+ }
27
+
28
+ function writeJson(path, value) {
29
+ mkdirSync(dirname(path), { recursive: true });
30
+ writeFileSync(path, JSON.stringify(value, null, 2), "utf8");
31
+ }
32
+
33
+ function packageRoot() {
34
+ return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
35
+ }
36
+
37
+ function readWorkspaceConfig() {
38
+ return readMergedOperatorConfig(process.cwd());
39
+ }
40
+
41
+ const { touchContinuationActivity } = await import("@amsterdamdatalabs/enact-operator/continuation");
42
+ const { findHeadQueuedFollowUp } = await import("@amsterdamdatalabs/enact-operator/continuationFollowUp");
43
+
44
+ function detectScopedWorkspace(prompt) {
45
+ if (typeof prompt !== 'string') return null;
46
+ const match = prompt.match(/Work only inside\s+"?([^"\n]+)"?/i);
47
+ if (!match) return null;
48
+ const candidate = match[1].trim();
49
+ if (!candidate) return null;
50
+ return candidate;
51
+ }
52
+
53
+ function chooseOperatorRoot(defaultRoot, prompt, skill) {
54
+ if (!RUNTIME_CLASS_SKILLS.has(skill)) {
55
+ return defaultRoot;
56
+ }
57
+ const scopedWorkspace = detectScopedWorkspace(prompt);
58
+ if (!scopedWorkspace) {
59
+ return defaultRoot;
60
+ }
61
+ const resolvedWorkspace = resolve(scopedWorkspace);
62
+ if (!existsSync(resolvedWorkspace)) {
63
+ return defaultRoot;
64
+ }
65
+ if (
66
+ existsSync(join(resolvedWorkspace, 'config.toml'))
67
+ || existsSync(join(resolvedWorkspace, 'package.json'))
68
+ || existsSync(join(resolvedWorkspace, 'README.md'))
69
+ ) {
70
+ try {
71
+ return rootDirFrom(resolvedWorkspace);
72
+ } catch {
73
+ return defaultRoot;
74
+ }
75
+ }
76
+ return defaultRoot;
77
+ }
78
+
79
+ function needsBootstrap(root) {
80
+ const installRegistry = readJson(layoutPath(root, "state", "install-registry.json"), null);
81
+ const tasksPath = layoutPath(root, "state", "tasks.json");
82
+ const tasks = readJson(tasksPath, null);
83
+ const session = readJson(layoutPath(root, "sessions", "current.json"), null);
84
+ return (
85
+ !existsSync(layoutDir(root)) ||
86
+ !Array.isArray(installRegistry?.entries) ||
87
+ installRegistry.entries.length === 0 ||
88
+ !Array.isArray(tasks) ||
89
+ !session
90
+ );
91
+ }
92
+
93
+ function runOperatorCommand(args, root) {
94
+ const candidate = "enact-operator";
95
+ const candidateCwd = candidate.endsWith(".ts") || candidate.endsWith(".js") ? packageRoot() : root;
96
+ if (candidate.endsWith(".ts")) {
97
+ return execFileSync("node", ["--experimental-strip-types", candidate, ...args], {
98
+ cwd: candidateCwd,
99
+ encoding: "utf8",
100
+ timeout: 15000,
101
+ stdio: ["ignore", "pipe", "pipe"],
102
+ });
103
+ }
104
+ if (candidate.endsWith(".js")) {
105
+ return execFileSync("node", [candidate, ...args], {
106
+ cwd: candidateCwd,
107
+ encoding: "utf8",
108
+ timeout: 15000,
109
+ stdio: ["ignore", "pipe", "pipe"],
110
+ });
111
+ }
112
+ return execFileSync(candidate, args, {
113
+ cwd: root,
114
+ encoding: "utf8",
115
+ timeout: 15000,
116
+ stdio: ["ignore", "pipe", "pipe"],
117
+ });
118
+ }
119
+
120
+ function runActivationEngine(root, prompt, payload) {
121
+ const script = join(packageRoot(), "runtime", "hooks", "resolveSkillActivation.mjs");
122
+ const input = JSON.stringify({
123
+ root,
124
+ prompt,
125
+ modelId: payload?.modelId ?? payload?.model_id ?? payload?.model,
126
+ headers: payload?.headers,
127
+ });
128
+ const output = execFileSync("node", [script], {
129
+ cwd: packageRoot(),
130
+ encoding: "utf8",
131
+ input,
132
+ timeout: 15000,
133
+ stdio: ["pipe", "pipe", "pipe"],
134
+ });
135
+ return String(output).trim();
136
+ }
137
+
138
+ async function ensureBootstrap(root) {
139
+ const config = readWorkspaceConfig();
140
+ if (payload?.skip_bootstrap === true || config?.operator?.skip_hook_bootstrap === true) {
141
+ return { bootstrapped: false, skipped: true };
142
+ }
143
+ if (!needsBootstrap(root)) {
144
+ return { bootstrapped: false };
145
+ }
146
+ try {
147
+ const { applySetup } = await import(join(packageRoot(), "dist", "shared", "core", "bootstrap.js"));
148
+ applySetup({ root });
149
+ return { bootstrapped: true };
150
+ } catch (err) {
151
+ const stderr = err.stderr ? String(err.stderr).trim() : String(err.message ?? err);
152
+ return { bootstrapped: false, error: stderr };
153
+ }
154
+ }
155
+
156
+ const RUNTIME_CLASS_SKILLS = new Set(["autopilot", "ralph", "ultrawork", "team"]);
157
+
158
+ function mcpHintForSkill(skill) {
159
+ const common = "If `operator_*` tools are not visible yet, call `tool_search` immediately to load the Enact Operator MCP namespace. If a namespace tool such as `mcp__enact_operator` is already visible, its nested `operator_*` functions are already callable and `tool_search` will only return the still-deferred subset. If the exact operator function you need is already present in the visible tool list, call it directly and skip `tool_search` for that name. Do not treat `tool_search` results as the full operator surface when a namespace is already present. Use Operator MCP tools before the `enact-operator` CLI.";
160
+ switch (skill) {
161
+ case "autopilot":
162
+ return `${common} If no external task id is linked, local Operator task discipline is mandatory: autopilot owns a local task. Read \`operator_task_list\` immediately and keep that task current instead of deferring tracking to AzDO. Search for \`operator_autopilot_status operator_task_list operator_operator_snapshot operator_hud operator_resume_from_repo_truth\`. Start with \`operator_autopilot_status\`, then \`operator_task_list\`, then continue with \`operator_autopilot_*\`, \`operator_operator_snapshot\`, \`operator_hud\`, and \`operator_resume_from_repo_truth\`.`;
163
+ case "ralph":
164
+ return `${common} If no external task id is linked, local Operator task discipline is mandatory: Ralph owns a local task. Read \`operator_task_list\` immediately and keep that task current instead of deferring tracking to AzDO. Search for \`operator_ralph_status operator_task_list operator_doctor operator_audit_provider_boundary operator_resume_from_repo_truth operator_hud\`. Start with \`operator_ralph_status\`, then \`operator_task_list\`, inspect the actual gates present in Ralph state, then continue with \`operator_ralph_*\` and only the gate tools that match the active gate set.`;
165
+ case "ultrawork":
166
+ return `${common} If no external task id is linked, local Operator task discipline is mandatory: ultrawork owns a local task. Read \`operator_task_list\` immediately and keep that task current instead of deferring tracking to AzDO. Search for \`operator_ultrawork_status operator_task_list operator_inbox_list operator_reviews_list operator_hud\`. Start with \`operator_ultrawork_status\`, then continue with \`operator_ultrawork_*\`, \`operator_task_list\`, \`operator_inbox_list\`, \`operator_reviews_list\`, and \`operator_hud\`.`;
167
+ case "ultragoal":
168
+ return `Use Operator MCP tools before the \`enact-operator\` CLI. These direct operator functions should already be visible in the callable tool list for this skill: \`mcp__enact_operator__operator_ultragoal_update\`, \`mcp__enact_operator__operator_session_start\`, \`mcp__enact_operator__operator_ultrawork_start\`, \`mcp__enact_operator__operator_ultrawork_link_plan\`, \`mcp__enact_operator__operator_ultrawork_link_task\`, \`mcp__enact_operator__operator_ultrawork_verify\`, \`mcp__enact_operator__operator_ultrawork_status\`, \`mcp__enact_operator__operator_ultrawork_complete\`, \`mcp__enact_operator__operator_contract_parity_run\`, \`mcp__enact_operator__operator_operator_snapshot\`, \`mcp__enact_operator__operator_hud\`, \`mcp__enact_operator__operator_workflow_reconcile\`, and \`mcp__enact_operator__operator_task_list\`. Call those direct names first. Do not call \`tool_search\` for these names unless one of those exact functions is absent from the visible tool list. If no external task id is linked, local Operator task discipline is mandatory: the active ultrawork burst under ultragoal owns a local task. Read \`operator_task_list\` immediately and keep that task current instead of deferring tracking to AzDO. Start with \`operator_ultragoal_update\`, then \`operator_session_start\`, then \`operator_ultrawork_start\`, then continue with the relevant \`operator_ultrawork_*\` tools, \`operator_task_list\`, \`operator_contract_parity_run\`, \`operator_operator_snapshot\`, \`operator_hud\`, and \`operator_workflow_reconcile\`.`;
169
+ case "team":
170
+ return `${common} When no external task id exists, local Operator task discipline is mandatory: queue the first local task immediately, then claim and review by local \`taskId\` instead of deferring tracking to AzDO. Search for \`operator_team_status operator_team_init operator_team_queue operator_task_list operator_team_claim operator_team_complete operator_team_review operator_team_inbox operator_team_logs operator_hud\`. Use MCP only. Important: for every \`operator_team_*\` call, \`root\` must be the repository root that owns \`.enact/operator\`, not a task subdirectory. Treat task folders as the code workspace, not the Operator state root. During bootstrap, do not fan out parallel MCP calls; confirm \`operator_team_status\` / \`operator_team_init\` sequentially first, then proceed to queue/claim/complete/review.`;
171
+ case "setup":
172
+ return `${common} Search for \`operator_setup operator_install_registry operator_doctor operator_audit_replacement_readiness\`. Prefer \`operator_setup\` for runtime layout only. Plugin install, hook registration, MCP registration, status, enable/disable, and uninstall are owned by \`enact-extensions install enact-operator --platform <surface>\`.`;
173
+ default:
174
+ return `${common} Search for the relevant \`operator_*\` tools for this skill and use CLI only when no MCP equivalent exists.`;
175
+ }
176
+ }
177
+
178
+ function buildAdditionalContext(result, repoRoot) {
179
+ const mcpHint = mcpHintForSkill(result.intent.skill);
180
+ const taskWorkspaceMatch = typeof result.intent.goal === 'string'
181
+ ? result.intent.goal.match(/Work only inside\s+(\S+)/i)
182
+ : null;
183
+ const taskWorkspace = taskWorkspaceMatch ? taskWorkspaceMatch[1] : null;
184
+ const operatorRoot = chooseOperatorRoot(repoRoot, result.intent.goal ?? '', result.intent.skill);
185
+ const continuationState = readJson(layoutPath(operatorRoot, "state", "continuation-state.json"), null);
186
+ let continuationHint = continuationState?.status === 'blocked' && continuationState?.resumeHint
187
+ ? ` Resume hint: ${continuationState.resumeHint}`
188
+ : '';
189
+ if (continuationState?.status === 'blocked' && findHeadQueuedFollowUp(operatorRoot)) {
190
+ continuationHint += ' Queued operator follow-up: check operator_continuation_followup_status or complete work then operator_continuation_followup_ack.';
191
+ }
192
+ if (result.decision === 'retarget' && result.requiredAction) {
193
+ return `Active ${result.intent.skill} goal differs from the new explicit ask. Do not silently reuse it. ${mcpHint}${continuationHint} Next action: ${result.requiredAction.tool}.`;
194
+ }
195
+ if (result.decision === 'reject') {
196
+ return `Ignored ${result.intent.skill} activation. ${result.reason ?? 'The prompt is not a durable execution goal.'} ${mcpHint}${continuationHint}`;
197
+ }
198
+ if (result.alreadyActive) {
199
+ const name = result.intent.skill.charAt(0).toUpperCase() + result.intent.skill.slice(1);
200
+ return `${name} already active. ${mcpHint}${continuationHint}`;
201
+ }
202
+ if (result.needsGoal) {
203
+ const name = result.intent.skill.charAt(0).toUpperCase() + result.intent.skill.slice(1);
204
+ return `${name} invoked without goal — please supply one. ${mcpHint}${continuationHint}`;
205
+ }
206
+ if (result.error) {
207
+ return `Skill activation error (${result.intent.skill}): ${result.error.slice(0, 200)} ${mcpHint}${continuationHint}`;
208
+ }
209
+ const variantSnippet =
210
+ result.selectedVariant && result.selectedVariant !== 'SKILL' && typeof result.selectedPromptContent === 'string'
211
+ ? ` Selected variant: ${result.selectedVariant} (${result.selectedPromptPath}).\n\n${result.selectedPromptContent}`
212
+ : '';
213
+ if (result.startedStateId) {
214
+ const name = result.intent.skill.charAt(0).toUpperCase() + result.intent.skill.slice(1);
215
+ const goalSnippet = result.intent.goal ? ` "${result.intent.goal.slice(0, 80)}"` : "";
216
+ if (result.intent.skill === 'team') {
217
+ const workspaceNote = taskWorkspace
218
+ ? ` Task workspace: ${taskWorkspace}.`
219
+ : '';
220
+ return `Activated ${name}:${goalSnippet} ${mcpHint}${continuationHint} Operator root: ${operatorRoot}.${workspaceNote} Immediate next MCP sequence: 1) operator_team_status { root: "${operatorRoot}" } 2) operator_team_queue { root: "${operatorRoot}", title: "<first concrete slice>" } 3) operator_team_claim { root: "${operatorRoot}", taskId: "<queued id>", executorId: "executor" }. Do not pass the task workspace as MCP root.${variantSnippet}`;
221
+ }
222
+ return `Activated ${name}:${goalSnippet} ${mcpHint}${continuationHint}${variantSnippet}`;
223
+ }
224
+ if (result.activated) {
225
+ const name = result.intent.skill.charAt(0).toUpperCase() + result.intent.skill.slice(1);
226
+ const goalSnippet = result.intent.goal ? ` "${result.intent.goal.slice(0, 80)}"` : "";
227
+ if (RUNTIME_CLASS_SKILLS.has(result.intent.skill)) {
228
+ return `Activated ${name}:${goalSnippet} ${mcpHint}${continuationHint}${variantSnippet}`;
229
+ }
230
+ return `Skill ${result.intent.skill} invoked. ${mcpHint}${continuationHint}${variantSnippet}`;
231
+ }
232
+ return `Skill ${result.intent.skill} activation recorded. ${mcpHint}${continuationHint}${variantSnippet}`;
233
+ }
234
+
235
+ const payload = readStdin();
236
+ const startedAt = Date.now();
237
+ const completeHook = registerHookFailureTrap({
238
+ payload,
239
+ hookEvent: "UserPromptSubmit",
240
+ startedAt,
241
+ });
242
+ const prompt = payload?.prompt ?? payload?.user_prompt ?? payload?.input ?? payload?.message ?? "";
243
+ const repoRoot = rootDirFrom(payload?.cwd ?? process.cwd());
244
+ const promptSkillIntent = (() => {
245
+ const match = String(prompt).match(/\$(?:enact-operator:)?([a-z][a-z0-9-]*)/i);
246
+ return match ? match[1].toLowerCase() : '';
247
+ })();
248
+ const root = chooseOperatorRoot(repoRoot, String(prompt), promptSkillIntent);
249
+ const operatorLayout = layoutDir(root);
250
+ mkdirSync(layoutPath(root, "logs"), { recursive: true });
251
+ appendFileSync(
252
+ layoutPath(root, "logs", "hooks.log"),
253
+ `${new Date().toISOString()} UserPromptSubmit ${String(prompt).slice(0, 160)}\n`,
254
+ "utf8",
255
+ );
256
+ touchContinuationActivity(root, "user-prompt-submit");
257
+
258
+ const memoryPath = layoutPath(root, "memory", "project.json");
259
+ const current = readJson(memoryPath, {
260
+ namespace: "project",
261
+ summary: "",
262
+ facts: [],
263
+ updatedAt: new Date().toISOString(),
264
+ });
265
+ const nextFacts = [...(current.facts ?? []), `Prompt: ${String(prompt).slice(0, 120)}`].slice(-12);
266
+ writeJson(memoryPath, {
267
+ ...current,
268
+ facts: nextFacts,
269
+ updatedAt: new Date().toISOString(),
270
+ });
271
+
272
+ const bootstrap = await ensureBootstrap(root);
273
+ let result = null;
274
+
275
+ if (bootstrap.error) {
276
+ // If bootstrap failed we cannot safely execute any state mutations.
277
+ const activationPayload = runActivationEngine(root, String(prompt), payload);
278
+ if (activationPayload && activationPayload !== "null") {
279
+ try {
280
+ result = JSON.parse(activationPayload);
281
+ result.error = `bootstrap failed: ${bootstrap.error}`;
282
+ } catch {
283
+ result = null;
284
+ }
285
+ }
286
+ } else {
287
+ const activationPayload = runActivationEngine(root, String(prompt), payload);
288
+ if (activationPayload && activationPayload !== "null") {
289
+ try {
290
+ result = JSON.parse(activationPayload);
291
+ } catch {
292
+ result = null;
293
+ }
294
+ }
295
+ }
296
+
297
+ if (result) {
298
+ const contextNote = buildAdditionalContext(result, repoRoot);
299
+ await emitHookFired({
300
+ payload,
301
+ hookEvent: "UserPromptSubmit",
302
+ outcome: "noop",
303
+ latencyMs: Date.now() - startedAt,
304
+ });
305
+ if (readHooksVerbose(root)) verboseLog("user-prompt-submit", `skill intent detected: ${result.intent?.skill ?? "unknown"} — context injected`);
306
+ completeHook();
307
+ process.stdout.write(
308
+ JSON.stringify({
309
+ continue: true,
310
+ hookSpecificOutput: {
311
+ hookEventName: "UserPromptSubmit",
312
+ additionalContext: contextNote,
313
+ },
314
+ }),
315
+ );
316
+ } else {
317
+ await emitHookFired({
318
+ payload,
319
+ hookEvent: "UserPromptSubmit",
320
+ outcome: "noop",
321
+ latencyMs: Date.now() - startedAt,
322
+ });
323
+ if (readHooksVerbose(root)) verboseLog("user-prompt-submit", "no-op (no skill intent detected, prompt passed through)");
324
+ completeHook();
325
+ process.stdout.write(JSON.stringify({ continue: true }));
326
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./shared/layout-dir.mjs";
2
+