@lumenflow/cli 3.1.2 → 3.1.3

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 (389) hide show
  1. package/README.md +36 -35
  2. package/dist/agent-issues-query.js +13 -8
  3. package/dist/agent-log-issue.js +15 -4
  4. package/dist/agent-session-end.js +15 -4
  5. package/dist/agent-session.js +18 -6
  6. package/dist/backlog-prune.js +1 -1
  7. package/dist/commands/integrate.js +32 -18
  8. package/dist/config-get.js +27 -15
  9. package/dist/config-set.js +104 -37
  10. package/dist/delegation-list.js +1 -1
  11. package/dist/doctor.js +19 -13
  12. package/dist/file-delete.js +1 -1
  13. package/dist/file-edit.js +1 -1
  14. package/dist/file-read.js +1 -1
  15. package/dist/file-write.js +1 -1
  16. package/dist/flow-bottlenecks.js +1 -1
  17. package/dist/flow-report.js +10 -9
  18. package/dist/gates.js +3 -2
  19. package/dist/git-branch.js +1 -1
  20. package/dist/git-diff.js +1 -1
  21. package/dist/git-log.js +1 -1
  22. package/dist/init.js +238 -42
  23. package/dist/initiative-add-wu.js +1 -1
  24. package/dist/initiative-bulk-assign-wus.js +1 -1
  25. package/dist/initiative-create.js +2 -2
  26. package/dist/initiative-edit.js +1 -1
  27. package/dist/initiative-list.js +1 -1
  28. package/dist/initiative-plan.js +1 -3
  29. package/dist/initiative-status.js +47 -6
  30. package/dist/lane-edit.js +19 -10
  31. package/dist/lane-health.js +13 -24
  32. package/dist/lane-lock.js +4 -5
  33. package/dist/lane-setup.js +5 -5
  34. package/dist/lane-status.js +4 -5
  35. package/dist/lane-suggest.js +9 -7
  36. package/dist/lane-validate.js +4 -5
  37. package/dist/lumenflow-upgrade.js +17 -11
  38. package/dist/mem-checkpoint.js +1 -1
  39. package/dist/mem-cleanup.js +6 -23
  40. package/dist/mem-context.js +1 -1
  41. package/dist/mem-create.js +1 -1
  42. package/dist/mem-delete.js +1 -1
  43. package/dist/mem-export.js +1 -1
  44. package/dist/mem-inbox.js +1 -1
  45. package/dist/mem-init.js +1 -1
  46. package/dist/mem-ready.js +1 -1
  47. package/dist/mem-recover.js +1 -1
  48. package/dist/mem-signal.js +1 -1
  49. package/dist/mem-start.js +1 -1
  50. package/dist/mem-summarize.js +8 -7
  51. package/dist/mem-triage.js +7 -5
  52. package/dist/metrics-cli.js +1 -1
  53. package/dist/metrics-snapshot.js +1 -1
  54. package/dist/onboard.js +295 -120
  55. package/dist/orchestrate-init-status.js +12 -7
  56. package/dist/orchestrate-initiative.js +23 -12
  57. package/dist/orchestrate-monitor.js +20 -8
  58. package/dist/pack-scaffold.js +1 -1
  59. package/dist/plan-create.js +1 -3
  60. package/dist/plan-edit.js +1 -3
  61. package/dist/plan-link.js +1 -3
  62. package/dist/plan-promote.js +1 -3
  63. package/dist/release.js +1 -3
  64. package/dist/signal-cleanup.js +4 -18
  65. package/dist/state-bootstrap.js +11 -8
  66. package/dist/state-cleanup.js +5 -19
  67. package/dist/state-doctor.js +213 -9
  68. package/dist/task-claim.js +1 -1
  69. package/dist/validate.js +1 -1
  70. package/dist/workspace-init.js +61 -61
  71. package/dist/wu-block.js +1 -1
  72. package/dist/wu-brief.js +1 -1
  73. package/dist/wu-claim.js +1 -1
  74. package/dist/wu-cleanup.js +1 -1
  75. package/dist/wu-create.js +3 -3
  76. package/dist/wu-delegate.js +1 -1
  77. package/dist/wu-deps.js +1 -1
  78. package/dist/wu-done.js +66 -34
  79. package/dist/wu-edit.js +1 -1
  80. package/dist/wu-infer-lane.js +1 -1
  81. package/dist/wu-preflight.js +1 -1
  82. package/dist/wu-prep.js +1 -1
  83. package/dist/wu-proto.js +1 -1
  84. package/dist/wu-prune.js +1 -1
  85. package/dist/wu-recover.js +1 -1
  86. package/dist/wu-release.js +1 -1
  87. package/dist/wu-repair.js +1 -1
  88. package/dist/wu-sandbox.js +40 -27
  89. package/dist/wu-status.js +1 -1
  90. package/dist/wu-unblock.js +1 -1
  91. package/dist/wu-unlock-lane.js +1 -1
  92. package/dist/wu-validate.js +1 -1
  93. package/package.json +12 -8
  94. package/packs/software-delivery/constants.ts +10 -0
  95. package/packs/software-delivery/extensions.ts +140 -0
  96. package/packs/software-delivery/gate-policies.ts +134 -0
  97. package/packs/software-delivery/index.ts +8 -0
  98. package/packs/software-delivery/manifest-schema.ts +236 -0
  99. package/packs/software-delivery/manifest.ts +417 -0
  100. package/packs/software-delivery/manifest.yaml +711 -0
  101. package/packs/software-delivery/pack-registration.ts +113 -0
  102. package/packs/software-delivery/tool-impl/agent-tools.ts +263 -0
  103. package/packs/software-delivery/tool-impl/delegation-tools.ts +66 -0
  104. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +219 -0
  105. package/packs/software-delivery/tool-impl/git-runner.ts +113 -0
  106. package/packs/software-delivery/tool-impl/git-tools.ts +316 -0
  107. package/packs/software-delivery/tool-impl/index.ts +15 -0
  108. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +720 -0
  109. package/packs/software-delivery/tool-impl/lane-lock.ts +246 -0
  110. package/packs/software-delivery/tool-impl/memory-tools.ts +415 -0
  111. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +21 -0
  112. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +328 -0
  113. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +687 -0
  114. package/packs/software-delivery/tool-impl/worker-loader.ts +52 -0
  115. package/packs/software-delivery/tool-impl/worktree-tools.ts +46 -0
  116. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +759 -0
  117. package/packs/software-delivery/tools/delegation-tools.ts +23 -0
  118. package/packs/software-delivery/tools/git-tools.ts +55 -0
  119. package/packs/software-delivery/tools/index.ts +8 -0
  120. package/packs/software-delivery/tools/lane-lock-tool.ts +37 -0
  121. package/packs/software-delivery/tools/types.ts +71 -0
  122. package/packs/software-delivery/tools/worktree-tools.ts +49 -0
  123. package/templates/core/LUMENFLOW.md.template +3 -3
  124. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +1 -1
  125. package/templates/core/ai/onboarding/lumenflow-force-usage.md.template +1 -1
  126. package/templates/core/ai/onboarding/quick-ref-commands.md.template +5 -5
  127. package/templates/core/ai/onboarding/starting-prompt.md.template +3 -3
  128. package/templates/core/ai/onboarding/vendor-support.md.template +1 -1
  129. package/templates/core/ai/onboarding/wu-create-checklist.md.template +1 -1
  130. package/dist/agent-issues-query.js.map +0 -1
  131. package/dist/agent-log-issue.js.map +0 -1
  132. package/dist/agent-session-end.js.map +0 -1
  133. package/dist/agent-session.js.map +0 -1
  134. package/dist/backlog-prune.js.map +0 -1
  135. package/dist/cli-entry-point.js +0 -149
  136. package/dist/cli-entry-point.js.map +0 -1
  137. package/dist/commands/integrate.js.map +0 -1
  138. package/dist/commands.js.map +0 -1
  139. package/dist/config-get.js.map +0 -1
  140. package/dist/config-set.js.map +0 -1
  141. package/dist/delegation-list.js.map +0 -1
  142. package/dist/deps-add.js +0 -259
  143. package/dist/deps-add.js.map +0 -1
  144. package/dist/deps-remove.js +0 -105
  145. package/dist/deps-remove.js.map +0 -1
  146. package/dist/docs-sync.js.map +0 -1
  147. package/dist/doctor.js.map +0 -1
  148. package/dist/file-delete.js.map +0 -1
  149. package/dist/file-edit.js.map +0 -1
  150. package/dist/file-read.js.map +0 -1
  151. package/dist/file-write.js.map +0 -1
  152. package/dist/flow-bottlenecks.js.map +0 -1
  153. package/dist/flow-report.js.map +0 -1
  154. package/dist/formatters.js +0 -151
  155. package/dist/formatters.js.map +0 -1
  156. package/dist/gate-defaults.js +0 -131
  157. package/dist/gate-defaults.js.map +0 -1
  158. package/dist/gate-registry.js +0 -73
  159. package/dist/gate-registry.js.map +0 -1
  160. package/dist/gates-graceful-degradation.js +0 -153
  161. package/dist/gates-graceful-degradation.js.map +0 -1
  162. package/dist/gates-plan-resolvers.js +0 -152
  163. package/dist/gates-plan-resolvers.js.map +0 -1
  164. package/dist/gates-runners.js +0 -509
  165. package/dist/gates-runners.js.map +0 -1
  166. package/dist/gates-types.js +0 -4
  167. package/dist/gates-types.js.map +0 -1
  168. package/dist/gates-utils.js +0 -323
  169. package/dist/gates-utils.js.map +0 -1
  170. package/dist/gates.js.map +0 -1
  171. package/dist/git-branch.js.map +0 -1
  172. package/dist/git-diff.js.map +0 -1
  173. package/dist/git-log.js.map +0 -1
  174. package/dist/git-status.js.map +0 -1
  175. package/dist/guard-locked.js +0 -172
  176. package/dist/guard-locked.js.map +0 -1
  177. package/dist/guard-main-branch.js +0 -217
  178. package/dist/guard-main-branch.js.map +0 -1
  179. package/dist/guard-worktree-commit.js +0 -163
  180. package/dist/guard-worktree-commit.js.map +0 -1
  181. package/dist/hooks/auto-checkpoint-utils.js +0 -54
  182. package/dist/hooks/auto-checkpoint-utils.js.map +0 -1
  183. package/dist/hooks/enforcement-checks.js +0 -399
  184. package/dist/hooks/enforcement-checks.js.map +0 -1
  185. package/dist/hooks/enforcement-generator.js +0 -139
  186. package/dist/hooks/enforcement-generator.js.map +0 -1
  187. package/dist/hooks/enforcement-sync.js +0 -385
  188. package/dist/hooks/enforcement-sync.js.map +0 -1
  189. package/dist/hooks/generators/auto-checkpoint.js +0 -125
  190. package/dist/hooks/generators/auto-checkpoint.js.map +0 -1
  191. package/dist/hooks/generators/enforce-worktree.js +0 -190
  192. package/dist/hooks/generators/enforce-worktree.js.map +0 -1
  193. package/dist/hooks/generators/index.js +0 -18
  194. package/dist/hooks/generators/index.js.map +0 -1
  195. package/dist/hooks/generators/pre-compact-checkpoint.js +0 -136
  196. package/dist/hooks/generators/pre-compact-checkpoint.js.map +0 -1
  197. package/dist/hooks/generators/require-wu.js +0 -117
  198. package/dist/hooks/generators/require-wu.js.map +0 -1
  199. package/dist/hooks/generators/session-start-recovery.js +0 -103
  200. package/dist/hooks/generators/session-start-recovery.js.map +0 -1
  201. package/dist/hooks/generators/signal-utils.js +0 -54
  202. package/dist/hooks/generators/signal-utils.js.map +0 -1
  203. package/dist/hooks/generators/warn-incomplete.js +0 -67
  204. package/dist/hooks/generators/warn-incomplete.js.map +0 -1
  205. package/dist/hooks/index.js +0 -10
  206. package/dist/hooks/index.js.map +0 -1
  207. package/dist/index.js.map +0 -1
  208. package/dist/init-detection.js +0 -232
  209. package/dist/init-detection.js.map +0 -1
  210. package/dist/init-lane-validation.js +0 -143
  211. package/dist/init-lane-validation.js.map +0 -1
  212. package/dist/init-scaffolding.js +0 -158
  213. package/dist/init-scaffolding.js.map +0 -1
  214. package/dist/init-templates.js +0 -1982
  215. package/dist/init-templates.js.map +0 -1
  216. package/dist/init.js.map +0 -1
  217. package/dist/initiative-add-wu.js.map +0 -1
  218. package/dist/initiative-bulk-assign-wus.js.map +0 -1
  219. package/dist/initiative-create.js.map +0 -1
  220. package/dist/initiative-edit.js.map +0 -1
  221. package/dist/initiative-list.js.map +0 -1
  222. package/dist/initiative-plan.js.map +0 -1
  223. package/dist/initiative-remove-wu.js.map +0 -1
  224. package/dist/initiative-status.js.map +0 -1
  225. package/dist/lane-edit.js.map +0 -1
  226. package/dist/lane-health.js.map +0 -1
  227. package/dist/lane-lifecycle-process.js +0 -366
  228. package/dist/lane-lifecycle-process.js.map +0 -1
  229. package/dist/lane-lock.js.map +0 -1
  230. package/dist/lane-setup.js.map +0 -1
  231. package/dist/lane-status.js.map +0 -1
  232. package/dist/lane-suggest.js.map +0 -1
  233. package/dist/lane-validate.js.map +0 -1
  234. package/dist/lifecycle-regression-harness.js +0 -181
  235. package/dist/lifecycle-regression-harness.js.map +0 -1
  236. package/dist/lumenflow-upgrade.js.map +0 -1
  237. package/dist/mem-checkpoint.js.map +0 -1
  238. package/dist/mem-cleanup.js.map +0 -1
  239. package/dist/mem-context.js.map +0 -1
  240. package/dist/mem-create.js.map +0 -1
  241. package/dist/mem-delete.js.map +0 -1
  242. package/dist/mem-export.js.map +0 -1
  243. package/dist/mem-inbox.js.map +0 -1
  244. package/dist/mem-index.js +0 -214
  245. package/dist/mem-index.js.map +0 -1
  246. package/dist/mem-init.js.map +0 -1
  247. package/dist/mem-profile.js +0 -210
  248. package/dist/mem-profile.js.map +0 -1
  249. package/dist/mem-promote.js +0 -257
  250. package/dist/mem-promote.js.map +0 -1
  251. package/dist/mem-ready.js.map +0 -1
  252. package/dist/mem-recover.js.map +0 -1
  253. package/dist/mem-signal.js.map +0 -1
  254. package/dist/mem-start.js.map +0 -1
  255. package/dist/mem-summarize.js.map +0 -1
  256. package/dist/mem-triage.js.map +0 -1
  257. package/dist/merge-block.js +0 -225
  258. package/dist/merge-block.js.map +0 -1
  259. package/dist/metrics-cli.js.map +0 -1
  260. package/dist/metrics-snapshot.js.map +0 -1
  261. package/dist/onboard.js.map +0 -1
  262. package/dist/onboarding-smoke-test.js +0 -418
  263. package/dist/onboarding-smoke-test.js.map +0 -1
  264. package/dist/orchestrate-init-status.js.map +0 -1
  265. package/dist/orchestrate-initiative.js.map +0 -1
  266. package/dist/orchestrate-monitor.js.map +0 -1
  267. package/dist/pack-author.js.map +0 -1
  268. package/dist/pack-hash.js.map +0 -1
  269. package/dist/pack-install.js.map +0 -1
  270. package/dist/pack-publish.js.map +0 -1
  271. package/dist/pack-scaffold.js.map +0 -1
  272. package/dist/pack-search.js.map +0 -1
  273. package/dist/pack-validate.js.map +0 -1
  274. package/dist/plan-create.js.map +0 -1
  275. package/dist/plan-edit.js.map +0 -1
  276. package/dist/plan-link.js.map +0 -1
  277. package/dist/plan-promote.js.map +0 -1
  278. package/dist/public-manifest.js +0 -920
  279. package/dist/public-manifest.js.map +0 -1
  280. package/dist/release.js.map +0 -1
  281. package/dist/rotate-progress.js +0 -253
  282. package/dist/rotate-progress.js.map +0 -1
  283. package/dist/session-coordinator.js +0 -303
  284. package/dist/session-coordinator.js.map +0 -1
  285. package/dist/shared-validators.js +0 -81
  286. package/dist/shared-validators.js.map +0 -1
  287. package/dist/signal-cleanup.js.map +0 -1
  288. package/dist/state-bootstrap.js.map +0 -1
  289. package/dist/state-cleanup.js.map +0 -1
  290. package/dist/state-doctor-fix.js +0 -226
  291. package/dist/state-doctor-fix.js.map +0 -1
  292. package/dist/state-doctor-stamps.js +0 -23
  293. package/dist/state-doctor-stamps.js.map +0 -1
  294. package/dist/state-doctor.js.map +0 -1
  295. package/dist/strict-progress.js +0 -255
  296. package/dist/strict-progress.js.map +0 -1
  297. package/dist/sync-templates.js.map +0 -1
  298. package/dist/task-claim.js.map +0 -1
  299. package/dist/trace-gen.js +0 -401
  300. package/dist/trace-gen.js.map +0 -1
  301. package/dist/validate-agent-skills.js +0 -223
  302. package/dist/validate-agent-skills.js.map +0 -1
  303. package/dist/validate-agent-sync.js +0 -151
  304. package/dist/validate-agent-sync.js.map +0 -1
  305. package/dist/validate-backlog-sync.js +0 -77
  306. package/dist/validate-backlog-sync.js.map +0 -1
  307. package/dist/validate-skills-spec.js +0 -211
  308. package/dist/validate-skills-spec.js.map +0 -1
  309. package/dist/validate.js.map +0 -1
  310. package/dist/validator-defaults.js +0 -107
  311. package/dist/validator-defaults.js.map +0 -1
  312. package/dist/validator-registry.js +0 -71
  313. package/dist/validator-registry.js.map +0 -1
  314. package/dist/workspace-init.js.map +0 -1
  315. package/dist/wu-block.js.map +0 -1
  316. package/dist/wu-brief.js.map +0 -1
  317. package/dist/wu-claim-branch.js +0 -123
  318. package/dist/wu-claim-branch.js.map +0 -1
  319. package/dist/wu-claim-cloud.js +0 -79
  320. package/dist/wu-claim-cloud.js.map +0 -1
  321. package/dist/wu-claim-mode.js +0 -82
  322. package/dist/wu-claim-mode.js.map +0 -1
  323. package/dist/wu-claim-output.js +0 -85
  324. package/dist/wu-claim-output.js.map +0 -1
  325. package/dist/wu-claim-repair-guidance.js +0 -12
  326. package/dist/wu-claim-repair-guidance.js.map +0 -1
  327. package/dist/wu-claim-resume-handler.js +0 -87
  328. package/dist/wu-claim-resume-handler.js.map +0 -1
  329. package/dist/wu-claim-state.js +0 -581
  330. package/dist/wu-claim-state.js.map +0 -1
  331. package/dist/wu-claim-validation.js +0 -457
  332. package/dist/wu-claim-validation.js.map +0 -1
  333. package/dist/wu-claim-worktree.js +0 -223
  334. package/dist/wu-claim-worktree.js.map +0 -1
  335. package/dist/wu-claim.js.map +0 -1
  336. package/dist/wu-cleanup-cloud.js +0 -78
  337. package/dist/wu-cleanup-cloud.js.map +0 -1
  338. package/dist/wu-cleanup.js.map +0 -1
  339. package/dist/wu-code-path-coverage.js +0 -83
  340. package/dist/wu-code-path-coverage.js.map +0 -1
  341. package/dist/wu-create-cloud.js +0 -30
  342. package/dist/wu-create-cloud.js.map +0 -1
  343. package/dist/wu-create-content.js +0 -264
  344. package/dist/wu-create-content.js.map +0 -1
  345. package/dist/wu-create-readiness.js +0 -59
  346. package/dist/wu-create-readiness.js.map +0 -1
  347. package/dist/wu-create-validation.js +0 -128
  348. package/dist/wu-create-validation.js.map +0 -1
  349. package/dist/wu-create.js.map +0 -1
  350. package/dist/wu-delegate.js.map +0 -1
  351. package/dist/wu-delete.js.map +0 -1
  352. package/dist/wu-deps.js.map +0 -1
  353. package/dist/wu-done-auto-cleanup.js +0 -203
  354. package/dist/wu-done-auto-cleanup.js.map +0 -1
  355. package/dist/wu-done-check.js +0 -38
  356. package/dist/wu-done-check.js.map +0 -1
  357. package/dist/wu-done-cloud.js +0 -48
  358. package/dist/wu-done-cloud.js.map +0 -1
  359. package/dist/wu-done-decay.js +0 -86
  360. package/dist/wu-done-decay.js.map +0 -1
  361. package/dist/wu-done.js.map +0 -1
  362. package/dist/wu-edit-operations.js +0 -399
  363. package/dist/wu-edit-operations.js.map +0 -1
  364. package/dist/wu-edit-validators.js +0 -282
  365. package/dist/wu-edit-validators.js.map +0 -1
  366. package/dist/wu-edit.js.map +0 -1
  367. package/dist/wu-infer-lane.js.map +0 -1
  368. package/dist/wu-preflight.js.map +0 -1
  369. package/dist/wu-prep.js.map +0 -1
  370. package/dist/wu-proto.js.map +0 -1
  371. package/dist/wu-prune.js.map +0 -1
  372. package/dist/wu-recover.js.map +0 -1
  373. package/dist/wu-release.js.map +0 -1
  374. package/dist/wu-repair.js.map +0 -1
  375. package/dist/wu-sandbox.js.map +0 -1
  376. package/dist/wu-spawn-completion.js +0 -33
  377. package/dist/wu-spawn-completion.js.map +0 -1
  378. package/dist/wu-spawn-prompt-builders.js +0 -1197
  379. package/dist/wu-spawn-prompt-builders.js.map +0 -1
  380. package/dist/wu-spawn-strategy-resolver.js +0 -322
  381. package/dist/wu-spawn-strategy-resolver.js.map +0 -1
  382. package/dist/wu-spawn.js +0 -59
  383. package/dist/wu-spawn.js.map +0 -1
  384. package/dist/wu-state-cloud.js +0 -41
  385. package/dist/wu-state-cloud.js.map +0 -1
  386. package/dist/wu-status.js.map +0 -1
  387. package/dist/wu-unblock.js.map +0 -1
  388. package/dist/wu-unlock-lane.js.map +0 -1
  389. package/dist/wu-validate.js.map +0 -1
@@ -1,1197 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: AGPL-3.0-only
3
- /**
4
- * WU Spawn Prompt Builders
5
- *
6
- * Extracted from wu-spawn.ts (WU-1652).
7
- * Contains all prompt section generators, formatters, and template helpers
8
- * used to build spawn/handoff prompts for sub-agents.
9
- *
10
- * @module wu-spawn-prompt-builders
11
- */
12
- import { existsSync } from 'node:fs';
13
- import path from 'node:path';
14
- import { minimatch } from 'minimatch';
15
- // WU-2252: Import invariants loader for spawn output injection
16
- import { loadInvariants, INVARIANT_TYPES } from '@lumenflow/core/invariants-runner';
17
- import { validateSpawnArgs, generateExecutionModeSection, generateThinkToolGuidance, } from '@lumenflow/core/wu-spawn-helpers';
18
- import { getConfig } from '@lumenflow/core/config';
19
- import { generateClientSkillsGuidance, generateSkillsSelectionSection, } from '@lumenflow/core/wu-spawn-skills';
20
- // WU-1253: Template loader for extracted prompt templates
21
- // WU-1898: Import evaluateCondition to gate templates by frontmatter conditions
22
- import { loadTemplatesWithOverrides, replaceTokens, evaluateCondition, } from '@lumenflow/core/template-loader';
23
- // WU-1192: Import prompt generation from Core (single source of truth)
24
- // WU-1203: Import generateAgentCoordinationSection from core for config-driven progress signals
25
- // WU-1288: Import policy-based test guidance and mandatory standards generators
26
- // WU-1900: Import generateDesignContextSection for UI-classified work
27
- import { TRUNCATION_WARNING_BANNER, SPAWN_END_SENTINEL, generateTestGuidance, generateAgentCoordinationSection, generatePolicyBasedTestGuidance, generateMandatoryStandards, generateEnforcementSummary, generateDesignContextSection, } from '@lumenflow/core/wu-spawn';
28
- // WU-1900: Import work classifier for domain-aware prompt generation
29
- import { classifyWork } from '@lumenflow/core/work-classifier';
30
- // WU-1288: Import resolvePolicy for methodology policy resolution
31
- import { resolvePolicy } from '@lumenflow/core/resolve-policy';
32
- // WU-1240: Import memory context integration for spawn prompts
33
- import { generateMemoryContextSection, checkMemoryLayerInitialized, getMemoryContextMaxSize, } from '@lumenflow/core/wu-spawn-context';
34
- // Re-export core constants for backwards compatibility
35
- export { TRUNCATION_WARNING_BANNER, SPAWN_END_SENTINEL, generateTestGuidance, generateAgentCoordinationSection, };
36
- // Re-export helper functions used by orchestration layer
37
- export { validateSpawnArgs, generateExecutionModeSection, generateThinkToolGuidance, generateMemoryContextSection, checkMemoryLayerInitialized, getMemoryContextMaxSize, };
38
- // Re-export skills functions used by orchestration layer
39
- export { generateClientSkillsGuidance, generateSkillsSelectionSection };
40
- // Re-export config
41
- export { getConfig };
42
- // Re-export policy resolver
43
- export { resolvePolicy };
44
- // ─── Mandatory Agent Detection ───
45
- /**
46
- * Mandatory agent trigger patterns.
47
- * Mirrors MANDATORY_TRIGGERS from orchestration.constants.ts.
48
- *
49
- * Note: For LumenFlow framework development, this is empty since we don't have
50
- * application-specific concerns. Projects using LumenFlow
51
- * should configure their own triggers based on their domain requirements.
52
- */
53
- const MANDATORY_TRIGGERS = {
54
- // No mandatory triggers for LumenFlow framework development.
55
- };
56
- /**
57
- * Detect mandatory agents based on code paths.
58
- *
59
- * @param {string[]} codePaths - Array of file paths
60
- * @returns {string[]} Array of mandatory agent names
61
- */
62
- export function detectMandatoryAgents(codePaths) {
63
- if (!codePaths || codePaths.length === 0) {
64
- return [];
65
- }
66
- const triggeredAgents = new Set();
67
- for (const [agentName, patterns] of Object.entries(MANDATORY_TRIGGERS)) {
68
- const isTriggered = codePaths.some((filePath) => patterns.some((pattern) => minimatch(filePath, pattern)));
69
- if (isTriggered) {
70
- triggeredAgents.add(agentName);
71
- }
72
- }
73
- return Array.from(triggeredAgents);
74
- }
75
- // ─── Formatters ───
76
- /**
77
- * Format acceptance criteria as markdown list
78
- *
79
- * @param {string[]|undefined} acceptance - Acceptance criteria array
80
- * @returns {string} Formatted acceptance criteria
81
- */
82
- export function formatAcceptance(acceptance) {
83
- if (!acceptance || acceptance.length === 0) {
84
- return '- No acceptance criteria defined';
85
- }
86
- return acceptance.map((item) => `- [ ] ${item}`).join('\n');
87
- }
88
- /**
89
- * Format spec_refs as markdown links
90
- *
91
- * @param {string[]|undefined} specRefs - Spec references array
92
- * @returns {string} Formatted references or empty string if none
93
- */
94
- function formatSpecRefs(specRefs) {
95
- if (!specRefs || specRefs.length === 0) {
96
- return '';
97
- }
98
- return specRefs.map((ref) => `- ${ref}`).join('\n');
99
- }
100
- /**
101
- * Format risks as markdown list
102
- *
103
- * @param {string[]|undefined} risks - Risks array
104
- * @returns {string} Formatted risks or empty string if none
105
- */
106
- function formatRisks(risks) {
107
- if (!risks || risks.length === 0) {
108
- return '';
109
- }
110
- return risks.map((risk) => `- ${risk}`).join('\n');
111
- }
112
- /**
113
- * Format manual tests as markdown checklist
114
- *
115
- * @param {string[]|undefined} manualTests - Manual test steps
116
- * @returns {string} Formatted tests or empty string if none
117
- */
118
- function formatManualTests(manualTests) {
119
- if (!manualTests || manualTests.length === 0) {
120
- return '';
121
- }
122
- return manualTests.map((test) => `- [ ] ${test}`).join('\n');
123
- }
124
- // ─── Implementation Context ───
125
- /**
126
- * Generate implementation context section (WU-1833)
127
- *
128
- * Includes spec_refs, notes, risks, and tests.manual if present.
129
- * Sections with no content are omitted to keep prompts lean.
130
- *
131
- * @param {object} doc - WU YAML document
132
- * @returns {string} Implementation context section or empty string
133
- */
134
- export function generateImplementationContext(doc) {
135
- const sections = [];
136
- // References (spec_refs)
137
- const refs = formatSpecRefs(doc.spec_refs);
138
- if (refs) {
139
- sections.push(`## References\n\n${refs}`);
140
- }
141
- // Implementation Notes
142
- if (doc.notes && doc.notes.trim()) {
143
- sections.push(`## Implementation Notes\n\n${doc.notes.trim()}`);
144
- }
145
- // Risks
146
- const risks = formatRisks(doc.risks);
147
- if (risks) {
148
- sections.push(`## Risks\n\n${risks}`);
149
- }
150
- // Manual Verification (tests.manual)
151
- const manualTests = formatManualTests(doc.tests?.manual);
152
- if (manualTests) {
153
- sections.push(`## Manual Verification\n\n${manualTests}`);
154
- }
155
- if (sections.length === 0) {
156
- return '';
157
- }
158
- return sections.join('\n\n---\n\n');
159
- }
160
- // ─── Invariants ───
161
- /**
162
- * Check if a code path matches an invariant based on type
163
- *
164
- * @param {object} invariant - Invariant definition
165
- * @param {string[]} codePaths - Array of code paths
166
- * @returns {boolean} True if code paths match the invariant
167
- */
168
- function codePathMatchesInvariant(invariant, codePaths) {
169
- switch (invariant.type) {
170
- case INVARIANT_TYPES.FORBIDDEN_FILE:
171
- case INVARIANT_TYPES.REQUIRED_FILE: {
172
- const invariantPath = invariant.path;
173
- if (!invariantPath) {
174
- return false;
175
- }
176
- return codePaths.some((p) => p === invariantPath || minimatch(p, invariantPath) || minimatch(invariantPath, p));
177
- }
178
- case INVARIANT_TYPES.MUTUAL_EXCLUSIVITY: {
179
- const invariantPaths = invariant.paths;
180
- if (!invariantPaths || invariantPaths.length === 0) {
181
- return false;
182
- }
183
- return codePaths.some((p) => invariantPaths.some((invPath) => p === invPath || minimatch(p, invPath)));
184
- }
185
- case INVARIANT_TYPES.FORBIDDEN_PATTERN:
186
- case INVARIANT_TYPES.REQUIRED_PATTERN:
187
- return (invariant.scope?.some((scopePattern) => codePaths.some((p) => minimatch(p, scopePattern))) ?? false);
188
- // WU-2254: forbidden-import uses 'from' glob instead of 'scope'
189
- case INVARIANT_TYPES.FORBIDDEN_IMPORT:
190
- return invariant.from ? codePaths.some((p) => minimatch(p, invariant.from)) : false;
191
- default:
192
- return false;
193
- }
194
- }
195
- /**
196
- * Format a single invariant for output
197
- *
198
- * @param {object} inv - Invariant definition
199
- * @returns {string[]} Lines of formatted output
200
- */
201
- function formatInvariantForOutput(inv) {
202
- const lines = [`### ${inv.id} (${inv.type})`, '', inv.description, ''];
203
- if (inv.message) {
204
- lines.push(`**Action:** ${inv.message}`, '');
205
- }
206
- if (inv.path) {
207
- lines.push(`**Path:** \`${inv.path}\``);
208
- }
209
- if (inv.paths) {
210
- const formattedPaths = inv.paths.map((p) => `\`${p}\``).join(', ');
211
- lines.push(`**Paths:** ${formattedPaths}`);
212
- }
213
- // WU-2254: forbidden-import specific fields
214
- if (inv.from) {
215
- lines.push(`**From:** \`${inv.from}\``);
216
- }
217
- if (inv.cannot_import && Array.isArray(inv.cannot_import)) {
218
- const formattedImports = inv.cannot_import.map((m) => `\`${m}\``).join(', ');
219
- lines.push(`**Cannot Import:** ${formattedImports}`);
220
- }
221
- // WU-2254: required-pattern specific fields
222
- if (inv.pattern &&
223
- (inv.type === INVARIANT_TYPES.REQUIRED_PATTERN ||
224
- inv.type === INVARIANT_TYPES.FORBIDDEN_PATTERN)) {
225
- lines.push(`**Pattern:** \`${inv.pattern}\``);
226
- }
227
- if (inv.scope && Array.isArray(inv.scope)) {
228
- const formattedScope = inv.scope.map((s) => `\`${s}\``).join(', ');
229
- lines.push(`**Scope:** ${formattedScope}`);
230
- }
231
- lines.push('');
232
- return lines;
233
- }
234
- /**
235
- * WU-2252: Generate invariants/prior-art section for code_paths
236
- *
237
- * Loads relevant invariants from invariants.yml and generates a section
238
- * that surfaces constraints and prior-art for the WU's code_paths.
239
- *
240
- * @param {string[]} codePaths - Array of code paths from the WU
241
- * @returns {string} Invariants/prior-art section or empty string if none relevant
242
- */
243
- export function generateInvariantsPriorArtSection(codePaths) {
244
- if (!codePaths || codePaths.length === 0) {
245
- return '';
246
- }
247
- // Try to load tools/invariants.yml
248
- const invariantsPath = path.resolve('tools/invariants.yml');
249
- if (!existsSync(invariantsPath)) {
250
- return '';
251
- }
252
- let invariants;
253
- try {
254
- invariants = loadInvariants(invariantsPath);
255
- }
256
- catch {
257
- return '';
258
- }
259
- if (!invariants || invariants.length === 0) {
260
- return '';
261
- }
262
- // Find relevant invariants based on code_paths
263
- const relevantInvariants = invariants.filter((inv) => codePathMatchesInvariant(inv, codePaths));
264
- if (relevantInvariants.length === 0) {
265
- return '';
266
- }
267
- // Format the section
268
- const lines = [
269
- '## Invariants/Prior-Art (WU-2252)',
270
- '',
271
- 'The following repo invariants are relevant to your code_paths:',
272
- '',
273
- ...relevantInvariants.flatMap(formatInvariantForOutput),
274
- '**IMPORTANT:** Do not create specs or acceptance criteria that conflict with these invariants.',
275
- ];
276
- return lines.join('\n');
277
- }
278
- // ─── Preamble and Constraints ───
279
- /**
280
- * Generate the context loading preamble using the strategy
281
- *
282
- * @param {string} id - WU ID
283
- * @param {SpawnStrategy} strategy - Client strategy
284
- * @returns {string} Context loading preamble
285
- */
286
- export function generatePreamble(id, strategy) {
287
- return strategy.getPreamble(id);
288
- }
289
- /**
290
- * Generate the constraints block (appended at end per Lost in the Middle research)
291
- *
292
- * WU-2247: Aligned with LumenFlow section 7.2 (stop-and-ask) and section 7.3 (anti-loop guard).
293
- * Includes item 6: MEMORY LAYER COORDINATION (WU-1589).
294
- *
295
- * WU-1900: TDD CHECKPOINT (constraint 1) is now conditional. It is omitted when:
296
- * - Work is classified as UI domain (smoke-test methodology)
297
- * - Policy methodology is 'none'
298
- *
299
- * @param {string} id - WU ID
300
- * @param {ConstraintsOptions} options - Options for conditional constraints
301
- * @returns {string} Constraints block
302
- */
303
- export function generateConstraints(id, options) {
304
- const includeTdd = options?.includeTddCheckpoint !== false;
305
- const tddCheckpointBlock = includeTdd
306
- ? `
307
- 1. TDD CHECKPOINT (VERIFY BEFORE IMPLEMENTATION)
308
- - Did you write tests BEFORE implementation?
309
- - Is there at least one failing test for each acceptance criterion?
310
- - Never skip the RED phase — failing tests prove the test works
311
-
312
- `
313
- : '';
314
- // WU-1900: Renumber constraints based on whether TDD is included
315
- const antiLoopNum = includeTdd ? 2 : 1;
316
- const stopAskNum = includeTdd ? 3 : 2;
317
- const verifyNum = includeTdd ? 4 : 3;
318
- const neverFabNum = includeTdd ? 5 : 4;
319
- const gitNum = includeTdd ? 6 : 5;
320
- const memNum = includeTdd ? 7 : 6;
321
- const skipGatesNum = includeTdd ? 8 : 7;
322
- return `---
323
-
324
- <constraints>
325
- CRITICAL RULES - ENFORCE BEFORE EVERY ACTION:
326
- ${tddCheckpointBlock}${antiLoopNum}. ANTI-LOOP GUARD (LumenFlow §7.3)
327
- - Max 3 attempts per unique error before escalating
328
- - If same error repeats 3x, STOP and report with full context
329
- - Retry with different approach, not same command
330
-
331
- ${stopAskNum}. STOP-AND-ASK TRIGGERS (LumenFlow §7.2 - narrow scope)
332
- - Policy changes, auth/permissions modifications
333
- - PII/safety issues, cloud spend, secrets, backups
334
- - Same error repeats 3x
335
- - For ordinary errors: fix and retry autonomously (up to 3 attempts)
336
-
337
- ${verifyNum}. VERIFY COMPLETION before reporting success
338
- - Run: node packages/@lumenflow/agent/dist/agent-verification.js ${id} (from shared checkout)
339
- - Exit 0 = passed, Exit 1 = INCOMPLETE
340
- - Never report "done" if verification fails
341
-
342
- ${neverFabNum}. NEVER FABRICATE COMPLETION
343
- - If blockers remain, report INCOMPLETE
344
- - If verification fails, summarize failures
345
- - Honesty over false completion
346
-
347
- ${gitNum}. GIT WORKFLOW (CRITICAL - GitHub rules reject merge commits)
348
- - GitHub REJECTS merge commits on main
349
- - ALWAYS use \`git rebase origin/main\` before push
350
- - Push to main via \`git push origin lane/...:main\` (fast-forward only)
351
- - NEVER use \`git merge\` on main branch
352
- - Let \`pnpm wu:done\` handle the merge workflow
353
-
354
- ${memNum}. MEMORY LAYER COORDINATION (INIT-007)
355
- - Use \`pnpm mem:checkpoint --wu ${id}\` to save progress before risky operations
356
- - Check \`pnpm mem:inbox --wu ${id}\` periodically for parallel signals from other agents
357
- - Checkpoint triggers (WU-1943): checkpoint after each acceptance criterion completed, checkpoint before gates, checkpoint every 30 tool calls
358
-
359
- ${skipGatesNum}. SKIP-GATES AUTONOMY (WU-1142)
360
- - If gates fail, first check if failure is pre-existing on main: \`git checkout main && pnpm gates\`
361
- - If failure exists on main (not your change), use: \`pnpm wu:done --id ${id} --skip-gates --reason "pre-existing on main" --fix-wu WU-XXXX\`
362
- - Do NOT ask for approval - autonomous skip-gates for pre-existing failures is correct
363
- - This prevents getting stuck on infrastructure debt
364
- </constraints>`;
365
- }
366
- export function generateCodexConstraints(id) {
367
- return `## Constraints (Critical)
368
-
369
- 1. **TDD checkpoint**: tests BEFORE implementation; never skip RED
370
- 2. **Stop on errors**: if UnsafeAny command fails, report BLOCKED (never DONE) with the error
371
- 3. **Verify before success**: run \`pnpm gates\` in the worktree, then run \`node packages/@lumenflow/agent/dist/agent-verification.js ${id}\` (from the shared checkout)
372
- 4. **No fabrication**: if blockers remain or verification fails, report INCOMPLETE
373
- 5. **Git workflow**: avoid merge commits; let \`pnpm wu:done\` handle completion
374
- 6. **Scope discipline**: stay within \`code_paths\`; capture out-of-scope issues via \`pnpm mem:create\`
375
- 7. **Skip-gates for pre-existing**: if gates fail due to pre-existing issue on main, use \`--skip-gates --reason "pre-existing" --fix-wu WU-XXX\``;
376
- }
377
- // ─── Section Generators ───
378
- /**
379
- * Generate mandatory agent advisory section
380
- *
381
- * @param {string[]} mandatoryAgents - Array of mandatory agent names
382
- * @param {string} _id - WU ID (reserved for future use)
383
- * @returns {string} Mandatory agent section or empty string
384
- */
385
- export function generateMandatoryAgentSection(mandatoryAgents, _id) {
386
- if (mandatoryAgents.length === 0) {
387
- return '';
388
- }
389
- const agentList = mandatoryAgents.map((agent) => ` - ${agent}`).join('\n');
390
- return `
391
- ## Mandatory Agents (MUST invoke before wu:done)
392
-
393
- Based on code_paths, the following agents MUST be invoked:
394
-
395
- ${agentList}
396
-
397
- Run: pnpm orchestrate:monitor to check agent status
398
- `;
399
- }
400
- /**
401
- * Generate effort scaling rules section (WU-1986)
402
- *
403
- * Based on Anthropic multi-agent research: helps agents decide when to
404
- * spawn sub-agents vs handle inline.
405
- *
406
- * @returns {string} Effort scaling section
407
- */
408
- export function generateEffortScalingRules() {
409
- return `## Effort Scaling (When to Spawn Sub-Agents)
410
-
411
- Use this heuristic to decide complexity:
412
-
413
- | Complexity | Approach | Tool Calls |
414
- |------------|----------|------------|
415
- | **Simple** (single file, <50 lines) | Handle inline | 3-10 |
416
- | **Moderate** (2-3 files, clear scope) | Handle inline | 10-20 |
417
- | **Complex** (4+ files, exploration needed) | Spawn Explore agent first | 20+ |
418
- | **Multi-domain** (cross-cutting concerns) | Spawn specialized sub-agents | Varies |
419
-
420
- **Rule**: If you need >30 tool calls for a subtask, consider spawning a sub-agent with a focused scope.`;
421
- }
422
- /**
423
- * Generate parallel tool call guidance (WU-1986)
424
- *
425
- * Based on Anthropic research: 3+ parallel tool calls significantly improve performance.
426
- *
427
- * @returns {string} Parallel tool call guidance
428
- */
429
- export function generateParallelToolCallGuidance() {
430
- return `## Parallel Tool Calls (Performance)
431
-
432
- **IMPORTANT**: Make 3+ tool calls in parallel when operations are independent.
433
-
434
- Good examples:
435
- - Reading multiple files simultaneously
436
- - Running independent grep searches
437
- - Spawning multiple Explore agents for different areas
438
-
439
- Bad examples:
440
- - Reading a file then editing it (sequential dependency)
441
- - Running tests then checking results (sequential)
442
-
443
- Parallelism reduces latency by 50-90% for complex tasks.`;
444
- }
445
- /**
446
- * Generate iterative search heuristics (WU-1986)
447
- *
448
- * Based on Anthropic research: start broad, narrow focus.
449
- *
450
- * @returns {string} Search heuristics section
451
- */
452
- export function generateIterativeSearchHeuristics() {
453
- return `## Search Strategy (Broad to Narrow)
454
-
455
- When exploring the codebase:
456
-
457
- 1. **Start broad**: Use Explore agent or glob patterns to understand structure
458
- 2. **Evaluate findings**: What patterns exist? What's relevant?
459
- 3. **Narrow focus**: Target specific files/functions based on findings
460
- 4. **Iterate**: Refine if initial approach misses the target
461
-
462
- Avoid: Jumping directly to specific file edits without understanding context.`;
463
- }
464
- /**
465
- * Generate token budget awareness section (WU-1986)
466
- *
467
- * @param {string} id - WU ID
468
- * @returns {string} Token budget section
469
- */
470
- export function generateTokenBudgetAwareness(id) {
471
- return `## Token Budget Awareness
472
-
473
- Context limit is ~200K tokens. Monitor your usage:
474
-
475
- - **At 50+ tool calls**: Create a checkpoint (\`pnpm mem:checkpoint --wu ${id}\`)
476
- - **At 100+ tool calls**: Consider spawning fresh sub-agent with focused scope
477
- - **Before risky operations**: Always checkpoint first
478
-
479
- If approaching limits, summarize progress and spawn continuation agent.`;
480
- }
481
- /**
482
- * Generate structured completion format (WU-1986)
483
- *
484
- * @param {string} id - WU ID
485
- * @returns {string} Completion format section
486
- */
487
- export function generateCompletionFormat(_id) {
488
- return `## Completion Report Format
489
-
490
- When finishing, provide structured output:
491
-
492
- \`\`\`
493
- ## Summary
494
- <1-3 sentences describing what was accomplished>
495
-
496
- ## Artifacts
497
- - Files modified: <list>
498
- - Tests added: <list>
499
- - Documentation updated: <list>
500
-
501
- ## Verification
502
- - Gates: <pass/fail>
503
- - Tests: <X passing, Y failing>
504
-
505
- ## Blockers (if UnsafeAny)
506
- - <blocker description>
507
-
508
- ## Follow-up (if needed)
509
- - <suggested next WU or action>
510
- \`\`\`
511
-
512
- This format enables orchestrator to track progress across waves.`;
513
- }
514
- /**
515
- * Generate quick fix commands section (WU-1987)
516
- *
517
- * Provides format/lint/typecheck commands for quick fixes before gates.
518
- *
519
- * @returns {string} Quick fix commands section
520
- */
521
- export function generateQuickFixCommands() {
522
- return `## Quick Fix Commands
523
-
524
- If gates fail, try these before investigating:
525
-
526
- \`\`\`bash
527
- pnpm format # Auto-fix formatting issues
528
- pnpm lint # Check linting (use --fix for auto-fix)
529
- pnpm typecheck # Check TypeScript types
530
- \`\`\`
531
-
532
- **Use before gates** to catch simple issues early. These are faster than full \`pnpm gates\`.`;
533
- }
534
- /**
535
- * Generate Worktree Block Recovery section (WU-1134)
536
- *
537
- * Provides guidance for agents when they're blocked by the worktree hook.
538
- * This happens when agents try to commit from main instead of the worktree.
539
- *
540
- * @param {string} worktreePath - Worktree path from WU YAML
541
- * @returns {string} Worktree block recovery section
542
- */
543
- export function generateWorktreeBlockRecoverySection(worktreePath) {
544
- return `## When Blocked by Worktree Hook
545
-
546
- If you encounter a "worktree required" or "commit blocked" error:
547
-
548
- 1. **Check existing worktrees**: \`git worktree list\`
549
- 2. **Navigate to the worktree**: \`cd ${worktreePath || 'worktrees/<lane>-wu-xxx'}\`
550
- 3. **Retry your operation** from within the worktree
551
- 4. **Use relative paths only** (never absolute paths starting with /)
552
-
553
- ### Common Causes
554
-
555
- - Running \`git commit\` from main checkout instead of worktree
556
- - Using absolute paths that bypass worktree isolation
557
- - Forgetting to \`cd\` to worktree after \`wu:claim\`
558
-
559
- ### Quick Fix
560
-
561
- \`\`\`bash
562
- # Check where you are
563
- pwd
564
- git worktree list
565
-
566
- # Navigate to your worktree
567
- cd ${worktreePath || 'worktrees/<lane>-wu-xxx'}
568
-
569
- # Retry your commit
570
- git add . && git commit -m "your message"
571
- \`\`\``;
572
- }
573
- /**
574
- * Generate Lane Selection section (WU-2107)
575
- *
576
- * Provides guidance on lane selection when creating new WUs.
577
- * Points agents to wu:infer-lane for automated lane suggestions.
578
- *
579
- * @returns {string} Lane Selection section
580
- */
581
- export function generateLaneSelectionSection() {
582
- return `## Lane Selection
583
-
584
- When creating new WUs, use the correct lane to enable parallelization:
585
-
586
- \`\`\`bash
587
- # Get lane suggestion based on code paths and description
588
- pnpm wu:infer-lane --id WU-XXX
589
-
590
- # Or infer from manual inputs
591
- pnpm wu:infer-lane --paths "tools/**" --desc "CLI improvements"
592
- \`\`\`
593
-
594
- **Lane taxonomy**: See \`.lumenflow.lane-inference.yaml\` for valid lanes and patterns.
595
-
596
- **Why lanes matter**: WIP=1 per lane means correct lane selection enables parallel work across lanes.`;
597
- }
598
- /**
599
- * Generate Worktree Path Guidance section (WU-2362)
600
- *
601
- * Provides guidance for sub-agents on working within worktrees, including
602
- * how to determine the worktree root and where to create stamps.
603
- *
604
- * Problem: CLAUDE_PROJECT_DIR is hook-only; sub-agents inherit parent cwd (main).
605
- * Solution: Use git rev-parse --show-toplevel to determine actual worktree root.
606
- *
607
- * @param {string|undefined} worktreePath - Worktree path from WU YAML
608
- * @returns {string} Worktree path guidance section
609
- */
610
- export function generateWorktreePathGuidance(worktreePath) {
611
- if (!worktreePath) {
612
- return '';
613
- }
614
- return `## Worktree Path Guidance (WU-2362)
615
-
616
- **Your worktree:** \`${worktreePath}\`
617
-
618
- ### Finding the Worktree Root
619
-
620
- Sub-agents may inherit the parent's cwd (main checkout). To find the actual worktree root:
621
-
622
- \`\`\`bash
623
- # Get the worktree root (not main checkout)
624
- git rev-parse --show-toplevel
625
- \`\`\`
626
-
627
- ### Stamp Creation
628
-
629
- When creating \`.lumenflow/\` stamps or other artifacts:
630
-
631
- 1. **ALWAYS** create stamps in the **worktree**, not main
632
- 2. Use \`git rev-parse --show-toplevel\` to get the correct base path
633
- 3. Stamps created on main will be lost when the worktree merges
634
-
635
- \`\`\`bash
636
- # CORRECT: Create stamp in worktree
637
- WORKTREE_ROOT=$(git rev-parse --show-toplevel)
638
- mkdir -p "$WORKTREE_ROOT/.lumenflow/agent-runs"
639
- touch "$WORKTREE_ROOT/.lumenflow/agent-runs/code-reviewer.stamp"
640
-
641
- # WRONG: Hardcoded path to main
642
- # touch /path/to/main/.lumenflow/agent-runs/code-reviewer.stamp
643
- \`\`\`
644
-
645
- ### Why This Matters
646
-
647
- - Stamps on main get overwritten by worktree merge
648
- - \`wu:done\` validates stamps exist in the worktree branch
649
- - Parallel WUs in other lanes won't see your stamps if on main`;
650
- }
651
- /**
652
- * Generate the Bug Discovery section (WU-1592, WU-2284)
653
- *
654
- * Instructs sub-agents to capture bugs found mid-WU via mem:create.
655
- * This enables scope-creep tracking and ensures discovered bugs
656
- * are not lost when agents encounter issues outside their WU scope.
657
- *
658
- * WU-2284: Added explicit prohibition against using wu:create directly
659
- * for discovered issues. Agents must use mem:create for capture, then
660
- * human triage decides whether to promote to a WU.
661
- *
662
- * @param {string} id - WU ID
663
- * @returns {string} Bug Discovery section
664
- */
665
- export function generateBugDiscoverySection(id) {
666
- return `## Bug Discovery (Mid-WU Issue Capture)
667
-
668
- If you discover a bug or issue **outside the scope of this WU**:
669
-
670
- 1. **Capture it immediately** using:
671
- \`\`\`bash
672
- pnpm mem:create 'Bug: <description>' --type discovery --tags bug,scope-creep --wu ${id}
673
- \`\`\`
674
-
675
- 2. **Continue with your WU** — do not fix bugs outside your scope
676
- 3. **Reference in notes** — mention the mem node ID in your completion notes
677
-
678
- ### NEVER use wu:create for discovered issues
679
-
680
- **Do NOT use \`wu:create\` directly for bugs discovered mid-WU.**
681
-
682
- - \`mem:create\` = **capture** (immediate, no human approval needed)
683
- - \`wu:create\` = **planned work** (requires human triage and approval)
684
-
685
- Discovered issues MUST go through human triage before becoming WUs.
686
- Using \`wu:create\` directly bypasses the triage workflow and creates
687
- unreviewed work items.
688
-
689
- ### When to Capture
690
-
691
- - Found a bug in code NOT in your \`code_paths\`
692
- - Discovered an issue that would require >10 lines to fix
693
- - Encountered broken behaviour unrelated to your acceptance criteria
694
-
695
- ### Triage Workflow
696
-
697
- After WU completion, bugs can be promoted to Bug WUs by humans:
698
- \`\`\`bash
699
- pnpm mem:triage --wu ${id} # List discoveries for this WU
700
- pnpm mem:triage --promote <node-id> --lane "<lane>" # Create Bug WU (human action)
701
- \`\`\`
702
-
703
- See: https://lumenflow.dev/reference/agent-invocation-guide/ §Bug Discovery`;
704
- }
705
- /**
706
- * Generate lane-specific guidance
707
- *
708
- * @param {string} lane - Lane name
709
- * @returns {string} Lane-specific guidance or empty string
710
- */
711
- export function generateLaneGuidance(lane) {
712
- if (!lane)
713
- return '';
714
- const laneParent = lane.split(':')[0].trim();
715
- const guidance = {
716
- Operations: `## Lane-Specific: Tooling
717
-
718
- - Update tool documentation in tools/README.md or relevant docs if adding new CLI commands`,
719
- Intelligence: `## Lane-Specific: Intelligence
720
-
721
- - All prompt changes require golden dataset evaluation (pnpm prompts:eval)
722
- - Follow prompt versioning guidelines in ai/prompts/README.md`,
723
- Experience: `## Lane-Specific: Experience
724
-
725
- - Follow design system tokens defined in the project
726
- - Ensure accessibility compliance (WCAG 2.1 AA)`,
727
- Core: `## Lane-Specific: Core
728
-
729
- - Maintain hexagonal architecture boundaries
730
- - Update domain model documentation if changing entities`,
731
- };
732
- return guidance[laneParent] || '';
733
- }
734
- /**
735
- * Generate the Action section based on WU claim status (WU-1745).
736
- *
737
- * If WU is already claimed (has claimed_at and worktree_path), tells agent
738
- * to continue in the existing worktree.
739
- *
740
- * If WU is unclaimed (status: ready), tells agent to run wu:claim first.
741
- *
742
- * @param {object} doc - WU YAML document
743
- * @param {string} id - WU ID
744
- * @returns {string} Action section content
745
- */
746
- export function generateActionSection(doc, id) {
747
- const isAlreadyClaimed = doc.claimed_at && doc.worktree_path;
748
- if (isAlreadyClaimed) {
749
- return `This WU is already claimed. Continue implementation in worktree following all standards above.
750
-
751
- cd ${doc.worktree_path}`;
752
- }
753
- // WU is unclaimed - agent needs to claim first
754
- const laneSlug = (doc.lane || 'unknown')
755
- .toLowerCase()
756
- .replace(/[:\s]+/g, '-')
757
- .replace(/-+/g, '-');
758
- return `**FIRST: Claim this WU before starting work:**
759
-
760
- \`\`\`bash
761
- pnpm wu:claim --id ${id} --lane "${doc.lane}"
762
- cd worktrees/${laneSlug}-${id.toLowerCase()}
763
- \`\`\`
764
-
765
- Then implement following all standards above.
766
-
767
- **CRITICAL:** Never use \`git worktree add\` directly. Always use \`pnpm wu:claim\` to ensure:
768
- - Event tracking in .lumenflow/state/wu-events.jsonl
769
- - Lane lock acquisition (WIP=1 enforcement)
770
- - Session tracking for context recovery`;
771
- }
772
- /**
773
- * Generate the Completion Workflow section for sub-agents (WU-2682).
774
- *
775
- * Explicitly instructs sub-agents to run wu:done autonomously after gates pass.
776
- * This prevents agents from asking permission instead of completing.
777
- *
778
- * @param {string} id - WU ID
779
- * @returns {string} Completion Workflow section
780
- */
781
- export function generateCompletionWorkflowSection(id) {
782
- return `## Completion Workflow
783
-
784
- **CRITICAL: Complete autonomously. Do NOT ask for permission.**
785
-
786
- After all acceptance criteria are satisfied:
787
-
788
- 1. Run gates in the worktree: \`pnpm gates\`
789
- 2. If gates pass, cd back to main checkout
790
- 3. Run: \`pnpm wu:done --id ${id}\`
791
-
792
- \`\`\`bash
793
- # From worktree, after gates pass:
794
- cd /path/to/main # NOT the worktree
795
- pnpm wu:done --id ${id}
796
- \`\`\`
797
-
798
- **wu:done** handles: merge to main, stamp creation, worktree cleanup.
799
-
800
- **Do not ask** "should I run wu:done?" — just run it when gates pass.`;
801
- }
802
- export function generateClientBlocksSection(clientContext) {
803
- if (!clientContext?.config?.blocks?.length)
804
- return '';
805
- const blocks = clientContext.config.blocks
806
- .map((block) => `### ${block.title}\n\n${block.content}`)
807
- .join('\n\n');
808
- return `## Client Guidance (${clientContext.name})\n\n${blocks}`;
809
- }
810
- // ─── Template Helpers ───
811
- /**
812
- * WU-1253: Try to load templates for spawn prompt sections.
813
- * WU-1898: Evaluates frontmatter conditions before including templates.
814
- *
815
- * Implements shadow mode: tries templates first, returns empty map
816
- * if templates aren't available (caller uses hardcoded fallback).
817
- *
818
- * Templates with conditions (e.g., "type !== 'documentation'") are
819
- * evaluated against the provided context. Templates whose condition
820
- * evaluates to false are excluded from the result map.
821
- *
822
- * @param clientName - Client name for overrides (e.g., 'claude-code', 'cursor')
823
- * @param context - Token values for replacement and condition evaluation
824
- * @returns Map of template id to processed content, empty if templates unavailable
825
- */
826
- export function tryLoadTemplates(clientName, context) {
827
- const result = new Map();
828
- try {
829
- const baseDir = process.cwd();
830
- const templates = loadTemplatesWithOverrides(baseDir, clientName);
831
- // WU-1898: Evaluate frontmatter conditions before including templates
832
- for (const [id, template] of templates) {
833
- const condition = template.frontmatter.condition;
834
- if (!evaluateCondition(condition, context)) {
835
- continue;
836
- }
837
- const processed = replaceTokens(template.content, context);
838
- result.set(id, processed);
839
- }
840
- }
841
- catch {
842
- // Template loading failed - return empty map for hardcoded fallback
843
- }
844
- return result;
845
- }
846
- /**
847
- * WU-1253: Build template context from WU document.
848
- * WU-1898: Accepts optional policy for condition evaluation of methodology templates.
849
- *
850
- * @param doc - WU YAML document
851
- * @param id - WU ID
852
- * @param policy - Optional resolved policy for methodology condition evaluation
853
- * @returns Context for template token replacement and condition evaluation
854
- */
855
- export function buildSpawnTemplateContext(doc, id, policy) {
856
- const lane = doc.lane || '';
857
- const laneParent = lane.split(':')[0]?.trim() || '';
858
- const type = (doc.type || 'feature').toLowerCase();
859
- const context = {
860
- WU_ID: id,
861
- LANE: lane,
862
- TYPE: type,
863
- TITLE: doc.title || '',
864
- DESCRIPTION: doc.description || '',
865
- WORKTREE_PATH: doc.worktree_path || '',
866
- laneParent,
867
- // Lowercase aliases for condition evaluation
868
- type,
869
- lane,
870
- worktreePath: doc.worktree_path || '',
871
- };
872
- // WU-1898: Add policy fields for methodology template condition evaluation
873
- if (policy) {
874
- context['policy.testing'] = policy.testing;
875
- context['policy.architecture'] = policy.architecture;
876
- }
877
- return context;
878
- }
879
- // ─── Full Prompt Generators ───
880
- /**
881
- * Generate the complete Task tool invocation
882
- *
883
- * @param {object} doc - WU YAML document
884
- * @param {string} id - WU ID
885
- * @param {SpawnStrategy} strategy - Client strategy
886
- * @param {object} [options={}] - Thinking mode options
887
- * @param {boolean} [options.thinking] - Whether extended thinking is enabled
888
- * @param {boolean} [options.noThinking] - Whether thinking is explicitly disabled
889
- * @param {string} [options.budget] - Token budget for thinking
890
- * @returns {string} Complete Task tool invocation
891
- */
892
- export function generateTaskInvocation(doc, id, strategy, options = {}) {
893
- const codePaths = doc.code_paths || [];
894
- const mandatoryAgents = detectMandatoryAgents(codePaths);
895
- const preamble = generatePreamble(id, strategy);
896
- const clientContext = options.client;
897
- const config = options.config || getConfig();
898
- // WU-1288: Resolve methodology policy from config
899
- // WU-1898: Moved before template loading so policy is available for condition evaluation
900
- const policy = resolvePolicy(config);
901
- // WU-1900: Run work classifier for domain-aware prompt generation
902
- const classificationConfig = config?.methodology?.work_classification;
903
- const classification = classifyWork({
904
- code_paths: doc.code_paths,
905
- lane: doc.lane,
906
- type: doc.type,
907
- description: doc.description,
908
- }, classificationConfig);
909
- // WU-1253: Try loading templates (shadow mode - falls back to hardcoded if unavailable)
910
- // WU-1681: Use resolved client from caller; fall back for template loading only
911
- // WU-1898: Pass policy to context for methodology template condition evaluation
912
- const clientName = options.client?.name || 'claude-code';
913
- const templateContext = buildSpawnTemplateContext(doc, id, policy);
914
- const templates = tryLoadTemplates(clientName, templateContext);
915
- // WU-1142: Use type-aware test guidance instead of hardcoded TDD directive
916
- // WU-1288: Use policy-based test guidance that respects methodology.testing config
917
- // WU-1253: Try template first, fall back to policy-based guidance
918
- // WU-1900: Pass classifier hint to test guidance
919
- const testGuidance = templates.get('tdd-directive') ||
920
- generatePolicyBasedTestGuidance(doc.type || 'feature', policy, {
921
- testMethodologyHint: classification.testMethodologyHint,
922
- });
923
- // WU-1288: Generate enforcement summary from resolved policy
924
- const enforcementSummary = generateEnforcementSummary(policy);
925
- // WU-1288: Generate mandatory standards based on resolved policy
926
- const mandatoryStandards = generateMandatoryStandards(policy);
927
- // WU-1142: Pass lane to get byLane skills
928
- const clientSkillsGuidance = generateClientSkillsGuidance(clientContext, doc.lane);
929
- // WU-1253: Try template for skills-selection, build skills section
930
- const skillsTemplateContent = templates.get('skills-selection');
931
- const skillsGuidanceSuffix = clientSkillsGuidance ? '\n' + clientSkillsGuidance : '';
932
- const skillsBaseContent = skillsTemplateContent || generateSkillsSelectionSection(doc, config, clientContext?.name);
933
- const skillsSection = skillsBaseContent + skillsGuidanceSuffix;
934
- const clientBlocks = generateClientBlocksSection(clientContext);
935
- const mandatorySection = generateMandatoryAgentSection(mandatoryAgents, id);
936
- const laneGuidance = generateLaneGuidance(doc.lane);
937
- // WU-1253: Try template for bug-discovery
938
- const bugDiscoverySection = templates.get('bug-discovery') || generateBugDiscoverySection(id);
939
- // WU-1253: Try template for constraints
940
- // WU-1900: Generate constraints with conditional TDD CHECKPOINT
941
- const shouldIncludeTddCheckpoint = classification.domain !== 'ui' && policy.testing !== 'none';
942
- const constraints = templates.get('constraints') ||
943
- generateConstraints(id, {
944
- includeTddCheckpoint: shouldIncludeTddCheckpoint,
945
- });
946
- const implementationContext = generateImplementationContext(doc);
947
- // WU-1900: Generate design context section for UI-classified work
948
- const designContextSection = generateDesignContextSection(classification);
949
- // WU-2252: Generate invariants/prior-art section for code_paths
950
- const invariantsPriorArt = generateInvariantsPriorArtSection(codePaths);
951
- // WU-1986: Anthropic multi-agent best practices sections
952
- // WU-1253: Try templates for these sections
953
- const effortScaling = templates.get('effort-scaling') || generateEffortScalingRules();
954
- const parallelToolCalls = templates.get('parallel-tool-calls') || generateParallelToolCallGuidance();
955
- const searchHeuristics = templates.get('search-heuristics') || generateIterativeSearchHeuristics();
956
- const tokenBudget = templates.get('token-budget') || generateTokenBudgetAwareness(id);
957
- const completionFormat = generateCompletionFormat(id);
958
- // WU-1987: Agent coordination and quick fix sections
959
- const agentCoordination = generateAgentCoordinationSection(id);
960
- // WU-1253: Try template for quick-fix-commands
961
- const quickFix = templates.get('quick-fix-commands') || generateQuickFixCommands();
962
- // WU-2107: Lane selection guidance
963
- // WU-1253: Try template for lane-selection
964
- const laneSelection = templates.get('lane-selection') || generateLaneSelectionSection();
965
- // WU-2362: Worktree path guidance for sub-agents
966
- const worktreeGuidance = generateWorktreePathGuidance(doc.worktree_path);
967
- const worktreePathHint = doc.worktree_path || `worktrees/<lane>-${id.toLowerCase()}`;
968
- // WU-1134: Worktree block recovery guidance
969
- // WU-1253: Try template for worktree-recovery
970
- const worktreeBlockRecovery = templates.get('worktree-recovery') || generateWorktreeBlockRecoverySection(worktreePathHint);
971
- // WU-1240: Memory context section
972
- // Include if explicitly enabled and not disabled via noContext
973
- const shouldIncludeMemoryContext = options.includeMemoryContext && !options.noContext;
974
- const memoryContextSection = shouldIncludeMemoryContext ? options.memoryContextContent || '' : '';
975
- // Generate thinking mode sections if applicable
976
- const executionModeSection = generateExecutionModeSection(options);
977
- const thinkToolGuidance = generateThinkToolGuidance(options);
978
- // Build optional sections string
979
- const thinkingSections = [executionModeSection, thinkToolGuidance]
980
- .filter((section) => section.length > 0)
981
- .join('\n\n---\n\n');
982
- const thinkingBlock = thinkingSections ? `${thinkingSections}\n\n---\n\n` : '';
983
- // Build the task prompt
984
- // WU-1131: Warning banner at start, end sentinel after constraints
985
- // WU-1142: Type-aware test guidance (TDD for code, format-only for docs, etc.)
986
- const taskPrompt = `${TRUNCATION_WARNING_BANNER}<task>
987
- ${preamble}
988
- </task>
989
-
990
- ---
991
-
992
- ${testGuidance}
993
-
994
- ---
995
-
996
- # ${id}: ${doc.title || 'Untitled'}
997
-
998
- ## WU Details
999
-
1000
- - **ID:** ${id}
1001
- - **Lane:** ${doc.lane || 'Unknown'}
1002
- - **Type:** ${doc.type || 'feature'}
1003
- - **Status:** ${doc.status || 'unknown'}
1004
- - **Worktree:** ${doc.worktree_path || `worktrees/<lane>-${id.toLowerCase()}`}
1005
-
1006
- ## Description
1007
-
1008
- ${doc.description || 'No description provided.'}
1009
-
1010
- ## Acceptance Criteria
1011
-
1012
- ${formatAcceptance(doc.acceptance)}
1013
-
1014
- ## Code Paths
1015
-
1016
- ${codePaths.length > 0 ? codePaths.map((p) => `- ${p}`).join('\n') : '- No code paths defined'}
1017
- ${mandatorySection}${invariantsPriorArt ? `---\n\n${invariantsPriorArt}\n\n` : ''}${implementationContext ? `---\n\n${implementationContext}\n\n` : ''}---
1018
-
1019
- ${thinkingBlock}${skillsSection}
1020
- ${memoryContextSection ? `---\n\n${memoryContextSection}\n\n` : ''}---
1021
-
1022
- ${mandatoryStandards}
1023
-
1024
- ---
1025
-
1026
- ${enforcementSummary}
1027
-
1028
- ${designContextSection ? `---\n\n${designContextSection}\n\n` : ''}${clientBlocks ? `---\n\n${clientBlocks}\n\n` : ''}${worktreeGuidance ? `---\n\n${worktreeGuidance}\n\n` : ''}---
1029
-
1030
- ${bugDiscoverySection}
1031
-
1032
- ---
1033
-
1034
- ${effortScaling}
1035
-
1036
- ---
1037
-
1038
- ${parallelToolCalls}
1039
-
1040
- ---
1041
-
1042
- ${searchHeuristics}
1043
-
1044
- ---
1045
-
1046
- ${tokenBudget}
1047
-
1048
- ---
1049
-
1050
- ${completionFormat}
1051
-
1052
- ---
1053
-
1054
- ${agentCoordination}
1055
-
1056
- ---
1057
-
1058
- ${quickFix}
1059
-
1060
- ---
1061
-
1062
- ${laneSelection}
1063
-
1064
- ---
1065
-
1066
- ${laneGuidance}${laneGuidance ? '\n\n---\n\n' : ''}## Action
1067
-
1068
- ${generateActionSection(doc, id)}
1069
-
1070
- ---
1071
-
1072
- ${worktreeBlockRecovery}
1073
-
1074
- ${constraints}
1075
-
1076
- ${SPAWN_END_SENTINEL}`;
1077
- // Escape special characters for XML output
1078
- const escapedPrompt = taskPrompt
1079
- .replace(/&/g, '&amp;')
1080
- .replace(/</g, '&lt;')
1081
- .replace(/>/g, '&gt;');
1082
- // Build the Task tool invocation block using antml format
1083
- // Using array join to avoid XML parsing issues
1084
- const openTag = '<' + 'antml:invoke name="Task">';
1085
- const closeTag = '</' + 'antml:invoke>';
1086
- const paramOpen = '<' + 'antml:parameter name="';
1087
- const paramClose = '</' + 'antml:parameter>';
1088
- const invocation = [
1089
- '<' + 'antml:function_calls>',
1090
- openTag,
1091
- `${paramOpen}subagent_type">general-purpose${paramClose}`,
1092
- `${paramOpen}description">Execute ${id}${paramClose}`,
1093
- `${paramOpen}prompt">${escapedPrompt}${paramClose}`,
1094
- closeTag,
1095
- '</' + 'antml:function_calls>',
1096
- ].join('\n');
1097
- return invocation;
1098
- }
1099
- export function generateCodexPrompt(doc, id, strategy, options = {}) {
1100
- const codePaths = doc.code_paths || [];
1101
- const mandatoryAgents = detectMandatoryAgents(codePaths);
1102
- const preamble = generatePreamble(id, strategy);
1103
- // WU-1142: Use type-aware test guidance instead of hardcoded TDD directive
1104
- const testGuidance = generateTestGuidance(doc.type || 'feature');
1105
- const mandatorySection = generateMandatoryAgentSection(mandatoryAgents, id);
1106
- const laneGuidance = generateLaneGuidance(doc.lane);
1107
- const bugDiscoverySection = generateBugDiscoverySection(id);
1108
- const implementationContext = generateImplementationContext(doc);
1109
- const action = generateActionSection(doc, id);
1110
- const constraints = generateCodexConstraints(id);
1111
- const clientContext = options.client;
1112
- const config = options.config || getConfig();
1113
- // WU-1142: Pass lane to get byLane skills
1114
- const clientSkillsGuidance = generateClientSkillsGuidance(clientContext, doc.lane);
1115
- const skillsSection = generateSkillsSelectionSection(doc, config, clientContext?.name) +
1116
- (clientSkillsGuidance ? `\n${clientSkillsGuidance}` : '');
1117
- const clientBlocks = generateClientBlocksSection(clientContext);
1118
- const executionModeSection = generateExecutionModeSection(options);
1119
- const thinkToolGuidance = generateThinkToolGuidance(options);
1120
- const thinkingSections = [executionModeSection, thinkToolGuidance]
1121
- .filter((section) => section.length > 0)
1122
- .join('\n\n---\n\n');
1123
- const thinkingBlock = thinkingSections ? `${thinkingSections}\n\n---\n\n` : '';
1124
- // WU-1134: Worktree block recovery guidance
1125
- const worktreePathHint = doc.worktree_path || `worktrees/<lane>-${id.toLowerCase()}`;
1126
- const worktreeBlockRecovery = generateWorktreeBlockRecoverySection(worktreePathHint);
1127
- // WU-1240: Memory context section
1128
- const shouldIncludeMemoryContext = options.includeMemoryContext && !options.noContext;
1129
- const memoryContextSection = shouldIncludeMemoryContext ? options.memoryContextContent || '' : '';
1130
- // WU-1131: Warning banner at start, end sentinel after constraints
1131
- // WU-1142: Type-aware test guidance
1132
- return `${TRUNCATION_WARNING_BANNER}# ${id}: ${doc.title || 'Untitled'}
1133
-
1134
- ${testGuidance}
1135
-
1136
- ---
1137
-
1138
- ## Context
1139
-
1140
- ${preamble}
1141
-
1142
- ---
1143
-
1144
- ## WU Details
1145
-
1146
- - **ID:** ${id}
1147
- - **Lane:** ${doc.lane || 'Unknown'}
1148
- - **Type:** ${doc.type || 'feature'}
1149
- - **Status:** ${doc.status || 'unknown'}
1150
- - **Worktree:** ${doc.worktree_path || `worktrees/<lane>-${id.toLowerCase()}`}
1151
-
1152
- ## Description
1153
-
1154
- ${doc.description || 'No description provided.'}
1155
-
1156
- ## Scope (code_paths)
1157
-
1158
- Only change files within these paths:
1159
-
1160
- ${codePaths.length > 0 ? codePaths.map((p) => `- ${p}`).join('\n') : '- No code paths defined'}
1161
-
1162
- ## Acceptance Criteria
1163
-
1164
- ${formatAcceptance(doc.acceptance)}
1165
-
1166
- ---
1167
-
1168
- ${skillsSection}
1169
- ${memoryContextSection ? `---\n\n${memoryContextSection}\n\n` : ''}---
1170
-
1171
- ## Action
1172
-
1173
- ${action}
1174
-
1175
- ---
1176
-
1177
- ## Verification
1178
-
1179
- - Run in worktree: \`pnpm gates\`
1180
- - From shared checkout: \`node packages/@lumenflow/agent/dist/agent-verification.js ${id}\`
1181
-
1182
- ---
1183
-
1184
- ${mandatorySection}${implementationContext ? `${implementationContext}\n\n---\n\n` : ''}${clientBlocks ? `${clientBlocks}\n\n---\n\n` : ''}${thinkingBlock}${bugDiscoverySection}
1185
-
1186
- ---
1187
-
1188
- ${laneGuidance}${laneGuidance ? '\n\n---\n\n' : ''}${worktreeBlockRecovery}
1189
-
1190
- ---
1191
-
1192
- ${constraints}
1193
-
1194
- ${SPAWN_END_SENTINEL}
1195
- `;
1196
- }
1197
- //# sourceMappingURL=wu-spawn-prompt-builders.js.map