@lumenflow/cli 5.5.0 → 5.7.14

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 (229) hide show
  1. package/README.md +41 -40
  2. package/dist/db-journal-recover.js +400 -0
  3. package/dist/db-journal-recover.js.map +1 -0
  4. package/dist/docs-sync.js +8 -3
  5. package/dist/docs-sync.js.map +1 -1
  6. package/dist/doctor.js +11 -0
  7. package/dist/doctor.js.map +1 -1
  8. package/dist/gate-defaults.js +37 -0
  9. package/dist/gate-defaults.js.map +1 -1
  10. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  11. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  12. package/dist/gates/prod-migration-drift.js +207 -0
  13. package/dist/gates/prod-migration-drift.js.map +1 -0
  14. package/dist/gates/test-over-deletion-guard.js +280 -0
  15. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  16. package/dist/gates-runners.js +44 -3
  17. package/dist/gates-runners.js.map +1 -1
  18. package/dist/gates.js +3 -2
  19. package/dist/gates.js.map +1 -1
  20. package/dist/hooks/config-resolver.js +16 -1
  21. package/dist/hooks/config-resolver.js.map +1 -1
  22. package/dist/hooks/dirty-guard.js +43 -2
  23. package/dist/hooks/dirty-guard.js.map +1 -1
  24. package/dist/hooks/git-status-parser.js +22 -8
  25. package/dist/hooks/git-status-parser.js.map +1 -1
  26. package/dist/init-templates.js +241 -0
  27. package/dist/init-templates.js.map +1 -1
  28. package/dist/init.js +122 -16
  29. package/dist/init.js.map +1 -1
  30. package/dist/lumenflow-setup.js +144 -0
  31. package/dist/lumenflow-setup.js.map +1 -0
  32. package/dist/lumenflow-upgrade.js +43 -1
  33. package/dist/lumenflow-upgrade.js.map +1 -1
  34. package/dist/mem-create.js +10 -1
  35. package/dist/mem-create.js.map +1 -1
  36. package/dist/mem-signal.js +21 -4
  37. package/dist/mem-signal.js.map +1 -1
  38. package/dist/orchestrate-initiative.js +28 -3
  39. package/dist/orchestrate-initiative.js.map +1 -1
  40. package/dist/public-manifest.js +17 -7
  41. package/dist/public-manifest.js.map +1 -1
  42. package/dist/release.js +53 -18
  43. package/dist/release.js.map +1 -1
  44. package/dist/wu-done-gates.js +13 -9
  45. package/dist/wu-done-gates.js.map +1 -1
  46. package/dist/wu-done.js +14 -2
  47. package/dist/wu-done.js.map +1 -1
  48. package/dist/wu-edit-operations.js +74 -0
  49. package/dist/wu-edit-operations.js.map +1 -1
  50. package/dist/wu-edit-validators.js +58 -0
  51. package/dist/wu-edit-validators.js.map +1 -1
  52. package/dist/wu-edit.js +106 -4
  53. package/dist/wu-edit.js.map +1 -1
  54. package/dist/wu-prep.js +57 -9
  55. package/dist/wu-prep.js.map +1 -1
  56. package/dist/wu-recover.js +6 -0
  57. package/dist/wu-recover.js.map +1 -1
  58. package/dist/wu-release.js +120 -2
  59. package/dist/wu-release.js.map +1 -1
  60. package/dist/wu-sizing-validation.js +47 -17
  61. package/dist/wu-sizing-validation.js.map +1 -1
  62. package/dist/wu-status.js +33 -0
  63. package/dist/wu-status.js.map +1 -1
  64. package/package.json +13 -12
  65. package/packs/agent-runtime/package.json +1 -1
  66. package/packs/sidekick/package.json +1 -1
  67. package/packs/software-delivery/package.json +1 -1
  68. package/templates/core/AGENTS.md.template +67 -3
  69. package/templates/core/LUMENFLOW.md.template +196 -47
  70. package/dist/distribution-preflight.js +0 -230
  71. package/dist/distribution-preflight.js.map +0 -1
  72. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  73. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  74. package/packs/agent-runtime/capability-factory.ts +0 -104
  75. package/packs/agent-runtime/constants.ts +0 -21
  76. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  77. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  78. package/packs/agent-runtime/delegation-tree.ts +0 -328
  79. package/packs/agent-runtime/index.ts +0 -20
  80. package/packs/agent-runtime/manifest.ts +0 -348
  81. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  82. package/packs/agent-runtime/orchestration.ts +0 -2027
  83. package/packs/agent-runtime/pack-registration.ts +0 -110
  84. package/packs/agent-runtime/policy-factory.ts +0 -165
  85. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  86. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  87. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  88. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  89. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  90. package/packs/agent-runtime/session-schema.ts +0 -467
  91. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  92. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  93. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  94. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  95. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  96. package/packs/agent-runtime/tools/index.ts +0 -4
  97. package/packs/agent-runtime/tools/types.ts +0 -47
  98. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  99. package/packs/agent-runtime/types.ts +0 -128
  100. package/packs/agent-runtime/vitest.config.ts +0 -11
  101. package/packs/sidekick/channel-ingress.ts +0 -137
  102. package/packs/sidekick/constants.ts +0 -10
  103. package/packs/sidekick/index.ts +0 -8
  104. package/packs/sidekick/manifest-schema.ts +0 -49
  105. package/packs/sidekick/manifest.ts +0 -512
  106. package/packs/sidekick/pack-registration.ts +0 -110
  107. package/packs/sidekick/policy-factory.ts +0 -38
  108. package/packs/sidekick/sidekick-events.ts +0 -694
  109. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  110. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  111. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  112. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  113. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  114. package/packs/sidekick/src/routines/commit.ts +0 -74
  115. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  116. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  117. package/packs/sidekick/tool-impl/index.ts +0 -29
  118. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  119. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  120. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  121. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  122. package/packs/sidekick/tool-impl/shared.ts +0 -125
  123. package/packs/sidekick/tool-impl/storage.ts +0 -325
  124. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  125. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  126. package/packs/sidekick/tools/channel-tools.ts +0 -53
  127. package/packs/sidekick/tools/index.ts +0 -9
  128. package/packs/sidekick/tools/memory-tools.ts +0 -53
  129. package/packs/sidekick/tools/routine-tools.ts +0 -53
  130. package/packs/sidekick/tools/system-tools.ts +0 -47
  131. package/packs/sidekick/tools/task-tools.ts +0 -61
  132. package/packs/sidekick/tools/types.ts +0 -57
  133. package/packs/sidekick/vitest.config.ts +0 -11
  134. package/packs/software-delivery/constants.ts +0 -10
  135. package/packs/software-delivery/extensions.ts +0 -140
  136. package/packs/software-delivery/gate-policies.ts +0 -134
  137. package/packs/software-delivery/index.ts +0 -8
  138. package/packs/software-delivery/manifest-schema.ts +0 -268
  139. package/packs/software-delivery/manifest.ts +0 -657
  140. package/packs/software-delivery/pack-registration.ts +0 -113
  141. package/packs/software-delivery/src/commands/index.ts +0 -5
  142. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  143. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  144. package/packs/software-delivery/src/config/index.ts +0 -8
  145. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  146. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  147. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  148. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  149. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  150. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  151. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  152. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  153. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  154. package/packs/software-delivery/src/constants/index.ts +0 -29
  155. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  156. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  157. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  158. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -500
  159. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  160. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  161. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  162. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  163. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  164. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  165. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  166. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  167. package/packs/software-delivery/src/domain/index.ts +0 -5
  168. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  169. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  170. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  171. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  172. package/packs/software-delivery/src/methodology/index.ts +0 -6
  173. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  174. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  175. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  176. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  177. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  178. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  179. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  180. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  181. package/packs/software-delivery/src/policy/index.ts +0 -22
  182. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  183. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  184. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  185. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  186. package/packs/software-delivery/src/ports/index.ts +0 -10
  187. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  188. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  189. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  190. package/packs/software-delivery/src/primitives/index.ts +0 -5
  191. package/packs/software-delivery/src/runtime/index.ts +0 -6
  192. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  193. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  194. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  195. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  196. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  197. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  198. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  199. package/packs/software-delivery/src/schemas/index.ts +0 -5
  200. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  201. package/packs/software-delivery/src/state/index.ts +0 -15
  202. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  203. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  204. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  205. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  206. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  207. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  208. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  209. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  210. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  211. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  212. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  213. package/packs/software-delivery/tool-impl/index.ts +0 -15
  214. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  215. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  216. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  217. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  218. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  219. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  220. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  221. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  222. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  223. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  224. package/packs/software-delivery/tools/git-tools.ts +0 -55
  225. package/packs/software-delivery/tools/index.ts +0 -8
  226. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  227. package/packs/software-delivery/tools/types.ts +0 -71
  228. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  229. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,807 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import type { ToolOutput } from '@lumenflow/kernel';
5
- import { RUNTIME_CLI_COMMANDS, runtimeCliAdapter } from './runtime-cli-adapter.js';
6
-
7
- const LIFECYCLE_TOOLS = {
8
- WU_STATUS: 'wu:status',
9
- WU_CREATE: 'wu:create',
10
- WU_CLAIM: 'wu:claim',
11
- WU_PREP: 'wu:prep',
12
- WU_DONE: 'wu:done',
13
- WU_SANDBOX: 'wu:sandbox',
14
- WU_PRUNE: 'wu:prune',
15
- WU_DELETE: 'wu:delete',
16
- WU_CLEANUP: 'wu:cleanup',
17
- WU_UNLOCK_LANE: 'wu:unlock-lane',
18
- WU_BRIEF: 'wu:brief',
19
- WU_DELEGATE: 'wu:delegate',
20
- WU_DEPS: 'wu:deps',
21
- WU_EDIT: 'wu:edit',
22
- WU_PROTO: 'wu:proto',
23
- WU_PREFLIGHT: 'wu:preflight',
24
- WU_VALIDATE: 'wu:validate',
25
- WU_BLOCK: 'wu:block',
26
- WU_UNBLOCK: 'wu:unblock',
27
- WU_RELEASE: 'wu:release',
28
- WU_RECOVER: 'wu:recover',
29
- WU_REPAIR: 'wu:repair',
30
- GATES: 'gates',
31
- } as const;
32
-
33
- type LifecycleToolName = (typeof LIFECYCLE_TOOLS)[keyof typeof LIFECYCLE_TOOLS];
34
-
35
- const LIFECYCLE_TOOL_ERROR_CODES: Record<LifecycleToolName, string> = {
36
- 'wu:status': 'WU_STATUS_ERROR',
37
- 'wu:create': 'WU_CREATE_ERROR',
38
- 'wu:claim': 'WU_CLAIM_ERROR',
39
- 'wu:prep': 'WU_PREP_ERROR',
40
- 'wu:done': 'WU_DONE_ERROR',
41
- 'wu:sandbox': 'WU_SANDBOX_ERROR',
42
- 'wu:prune': 'WU_PRUNE_ERROR',
43
- 'wu:delete': 'WU_DELETE_ERROR',
44
- 'wu:cleanup': 'WU_CLEANUP_ERROR',
45
- 'wu:unlock-lane': 'WU_UNLOCK_LANE_ERROR',
46
- 'wu:brief': 'WU_BRIEF_ERROR',
47
- 'wu:delegate': 'WU_DELEGATE_ERROR',
48
- 'wu:deps': 'WU_DEPS_ERROR',
49
- 'wu:edit': 'WU_EDIT_ERROR',
50
- 'wu:proto': 'WU_PROTO_ERROR',
51
- 'wu:preflight': 'WU_PREFLIGHT_ERROR',
52
- 'wu:validate': 'WU_VALIDATE_ERROR',
53
- 'wu:block': 'WU_BLOCK_ERROR',
54
- 'wu:unblock': 'WU_UNBLOCK_ERROR',
55
- 'wu:release': 'WU_RELEASE_ERROR',
56
- 'wu:recover': 'WU_RECOVER_ERROR',
57
- 'wu:repair': 'WU_REPAIR_ERROR',
58
- gates: 'GATES_ERROR',
59
- };
60
-
61
- interface LifecycleToolCommandSpec {
62
- command: (typeof RUNTIME_CLI_COMMANDS)[keyof typeof RUNTIME_CLI_COMMANDS];
63
- }
64
-
65
- const LIFECYCLE_TOOL_COMMAND_SPECS: Record<LifecycleToolName, LifecycleToolCommandSpec> = {
66
- 'wu:status': { command: RUNTIME_CLI_COMMANDS.WU_STATUS },
67
- 'wu:create': { command: RUNTIME_CLI_COMMANDS.WU_CREATE },
68
- 'wu:claim': { command: RUNTIME_CLI_COMMANDS.WU_CLAIM },
69
- 'wu:prep': { command: RUNTIME_CLI_COMMANDS.WU_PREP },
70
- 'wu:done': { command: RUNTIME_CLI_COMMANDS.WU_DONE },
71
- 'wu:sandbox': { command: RUNTIME_CLI_COMMANDS.WU_SANDBOX },
72
- 'wu:prune': { command: RUNTIME_CLI_COMMANDS.WU_PRUNE },
73
- 'wu:delete': { command: RUNTIME_CLI_COMMANDS.WU_DELETE },
74
- 'wu:cleanup': { command: RUNTIME_CLI_COMMANDS.WU_CLEANUP },
75
- 'wu:unlock-lane': { command: RUNTIME_CLI_COMMANDS.WU_UNLOCK_LANE },
76
- 'wu:brief': { command: RUNTIME_CLI_COMMANDS.WU_BRIEF },
77
- 'wu:delegate': { command: RUNTIME_CLI_COMMANDS.WU_DELEGATE },
78
- 'wu:deps': { command: RUNTIME_CLI_COMMANDS.WU_DEPS },
79
- 'wu:edit': { command: RUNTIME_CLI_COMMANDS.WU_EDIT },
80
- 'wu:proto': { command: RUNTIME_CLI_COMMANDS.WU_PROTO },
81
- 'wu:preflight': { command: RUNTIME_CLI_COMMANDS.WU_PREFLIGHT },
82
- 'wu:validate': { command: RUNTIME_CLI_COMMANDS.WU_VALIDATE },
83
- 'wu:block': { command: RUNTIME_CLI_COMMANDS.WU_BLOCK },
84
- 'wu:unblock': { command: RUNTIME_CLI_COMMANDS.WU_UNBLOCK },
85
- 'wu:release': { command: RUNTIME_CLI_COMMANDS.WU_RELEASE },
86
- 'wu:recover': { command: RUNTIME_CLI_COMMANDS.WU_RECOVER },
87
- 'wu:repair': { command: RUNTIME_CLI_COMMANDS.WU_REPAIR },
88
- gates: { command: RUNTIME_CLI_COMMANDS.GATES },
89
- };
90
-
91
- const MISSING_PARAMETER_MESSAGES = {
92
- ID_REQUIRED: 'id is required',
93
- COMMAND_REQUIRED: 'command is required',
94
- PARENT_WU_REQUIRED: 'parent_wu is required',
95
- LANE_REQUIRED: 'lane is required',
96
- TITLE_REQUIRED: 'title is required',
97
- REASON_REQUIRED: 'reason is required',
98
- SANDBOX_COMMAND_REQUIRED: 'sandbox_command is required when sandbox=true',
99
- } as const;
100
-
101
- const LIFECYCLE_FLAGS = {
102
- DESCRIPTION: '--description',
103
- CODE_PATHS: '--code-paths',
104
- } as const;
105
-
106
- interface CommandExecutionResult {
107
- ok: boolean;
108
- status: number;
109
- stdout: string;
110
- stderr: string;
111
- executionError?: string;
112
- }
113
-
114
- interface RunOptions {
115
- parseJson?: boolean;
116
- }
117
-
118
- function toRecord(input: unknown): Record<string, unknown> {
119
- if (input && typeof input === 'object') {
120
- return input as Record<string, unknown>;
121
- }
122
- return {};
123
- }
124
-
125
- function toStringValue(value: unknown): string | null {
126
- if (typeof value !== 'string') {
127
- return null;
128
- }
129
- const trimmed = value.trim();
130
- return trimmed.length > 0 ? trimmed : null;
131
- }
132
-
133
- function toStringArray(value: unknown): string[] {
134
- if (!Array.isArray(value)) {
135
- return [];
136
- }
137
- return value
138
- .map((entry) => toStringValue(entry))
139
- .filter((entry): entry is string => entry !== null);
140
- }
141
-
142
- function toIntegerString(value: unknown): string | null {
143
- if (typeof value === 'number' && Number.isFinite(value)) {
144
- return String(Math.trunc(value));
145
- }
146
- if (typeof value === 'string') {
147
- const trimmed = value.trim();
148
- return trimmed.length > 0 ? trimmed : null;
149
- }
150
- return null;
151
- }
152
-
153
- async function runLifecycleCommand(
154
- toolName: LifecycleToolName,
155
- args: string[],
156
- ): Promise<CommandExecutionResult> {
157
- const spec = LIFECYCLE_TOOL_COMMAND_SPECS[toolName];
158
- return runtimeCliAdapter.run(spec.command, args);
159
- }
160
-
161
- function createMissingParameterOutput(message: string): ToolOutput {
162
- return {
163
- success: false,
164
- error: {
165
- code: 'MISSING_PARAMETER',
166
- message,
167
- },
168
- };
169
- }
170
-
171
- function createFailureOutput(
172
- toolName: LifecycleToolName,
173
- execution: CommandExecutionResult,
174
- ): ToolOutput {
175
- const stderrMessage = execution.stderr.trim();
176
- const stdoutMessage = execution.stdout.trim();
177
- const message =
178
- execution.executionError ??
179
- (stderrMessage.length > 0
180
- ? stderrMessage
181
- : stdoutMessage.length > 0
182
- ? stdoutMessage
183
- : `${toolName} failed`);
184
- return {
185
- success: false,
186
- error: {
187
- code: LIFECYCLE_TOOL_ERROR_CODES[toolName],
188
- message,
189
- details: {
190
- exit_code: execution.status,
191
- stdout: execution.stdout,
192
- stderr: execution.stderr,
193
- },
194
- },
195
- };
196
- }
197
-
198
- function parseJsonOutput(stdout: string): unknown | null {
199
- const trimmed = stdout.trim();
200
- if (trimmed.length === 0) {
201
- return null;
202
- }
203
- try {
204
- return JSON.parse(trimmed) as unknown;
205
- } catch {
206
- return null;
207
- }
208
- }
209
-
210
- function createSuccessOutput(
211
- toolName: LifecycleToolName,
212
- execution: CommandExecutionResult,
213
- options: RunOptions,
214
- ): ToolOutput {
215
- const parsedJson = options.parseJson ? parseJsonOutput(execution.stdout) : null;
216
- if (parsedJson !== null) {
217
- return {
218
- success: true,
219
- data: parsedJson,
220
- };
221
- }
222
-
223
- const message = execution.stdout.trim().length > 0 ? execution.stdout.trim() : `${toolName} ran`;
224
- return {
225
- success: true,
226
- data: {
227
- message,
228
- },
229
- };
230
- }
231
-
232
- async function executeLifecycleTool(
233
- toolName: LifecycleToolName,
234
- args: string[],
235
- options: RunOptions = {},
236
- ): Promise<ToolOutput> {
237
- const execution = await runLifecycleCommand(toolName, args);
238
- if (!execution.ok) {
239
- return createFailureOutput(toolName, execution);
240
- }
241
- return createSuccessOutput(toolName, execution, options);
242
- }
243
-
244
- function pushRepeatedFlag(args: string[], flag: string, values: string[]): void {
245
- for (const value of values) {
246
- args.push(flag, value);
247
- }
248
- }
249
-
250
- function appendWuPromptArgs(parsed: Record<string, unknown>, args: string[]): void {
251
- const client = toStringValue(parsed.client);
252
- if (client) {
253
- args.push('--client', client);
254
- }
255
- if (parsed.thinking === true) {
256
- args.push('--thinking');
257
- }
258
- const budget = toIntegerString(parsed.budget);
259
- if (budget) {
260
- args.push('--budget', budget);
261
- }
262
- const parentWu = toStringValue(parsed.parent_wu);
263
- if (parentWu) {
264
- args.push('--parent-wu', parentWu);
265
- }
266
- if (parsed.no_context === true) {
267
- args.push('--no-context');
268
- }
269
- }
270
-
271
- export async function wuCreateTool(input: unknown): Promise<ToolOutput> {
272
- const parsed = toRecord(input);
273
- const lane = toStringValue(parsed.lane);
274
- const title = toStringValue(parsed.title);
275
- if (!lane) {
276
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.LANE_REQUIRED);
277
- }
278
- if (!title) {
279
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.TITLE_REQUIRED);
280
- }
281
-
282
- const args: string[] = ['--lane', lane, '--title', title];
283
- const id = toStringValue(parsed.id);
284
- if (id) {
285
- args.push('--id', id);
286
- }
287
- const description = toStringValue(parsed.description);
288
- if (description) {
289
- args.push(LIFECYCLE_FLAGS.DESCRIPTION, description);
290
- }
291
- pushRepeatedFlag(args, '--acceptance', toStringArray(parsed.acceptance));
292
- pushRepeatedFlag(args, LIFECYCLE_FLAGS.CODE_PATHS, toStringArray(parsed.code_paths));
293
- const exposure = toStringValue(parsed.exposure);
294
- if (exposure) {
295
- args.push('--exposure', exposure);
296
- }
297
-
298
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_CREATE, args);
299
- }
300
-
301
- export async function wuClaimTool(input: unknown): Promise<ToolOutput> {
302
- const parsed = toRecord(input);
303
- const id = toStringValue(parsed.id);
304
- const lane = toStringValue(parsed.lane);
305
- if (!id) {
306
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
307
- }
308
- if (!lane) {
309
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.LANE_REQUIRED);
310
- }
311
-
312
- const args: string[] = ['--id', id, '--lane', lane];
313
- if (parsed.cloud === true) {
314
- args.push('--cloud');
315
- }
316
- if (parsed.branch_only === true) {
317
- args.push('--branch-only');
318
- }
319
- if (parsed.pr_mode === true) {
320
- args.push('--pr-mode');
321
- }
322
- if (parsed.sandbox === true) {
323
- const sandboxCommand = toStringArray(parsed.sandbox_command);
324
- if (sandboxCommand.length === 0) {
325
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.SANDBOX_COMMAND_REQUIRED);
326
- }
327
- args.push('--sandbox', '--', ...sandboxCommand);
328
- }
329
-
330
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_CLAIM, args);
331
- }
332
-
333
- export async function wuPrepTool(input: unknown): Promise<ToolOutput> {
334
- const parsed = toRecord(input);
335
- const id = toStringValue(parsed.id);
336
- if (!id) {
337
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
338
- }
339
-
340
- const args = ['--id', id];
341
- if (parsed.docs_only === true) {
342
- args.push('--docs-only');
343
- }
344
- if (parsed.full_tests === true) {
345
- args.push('--full-tests');
346
- }
347
-
348
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_PREP, args);
349
- }
350
-
351
- export async function wuDoneTool(input: unknown): Promise<ToolOutput> {
352
- const parsed = toRecord(input);
353
- const id = toStringValue(parsed.id);
354
- if (!id) {
355
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
356
- }
357
-
358
- const args = ['--id', id];
359
- if (parsed.skip_gates === true) {
360
- args.push('--skip-gates');
361
- const reason = toStringValue(parsed.reason);
362
- if (reason) {
363
- args.push('--reason', reason);
364
- }
365
- const fixWu = toStringValue(parsed.fix_wu);
366
- if (fixWu) {
367
- args.push('--fix-wu', fixWu);
368
- }
369
- }
370
-
371
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_DONE, args);
372
- }
373
-
374
- export async function wuSandboxTool(input: unknown): Promise<ToolOutput> {
375
- const parsed = toRecord(input);
376
- const id = toStringValue(parsed.id);
377
- if (!id) {
378
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
379
- }
380
-
381
- const command = toStringArray(parsed.command);
382
- if (command.length === 0) {
383
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.COMMAND_REQUIRED);
384
- }
385
-
386
- const args: string[] = ['--id', id];
387
- const worktree = toStringValue(parsed.worktree);
388
- if (worktree) {
389
- args.push('--worktree', worktree);
390
- }
391
- args.push('--', ...command);
392
-
393
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_SANDBOX, args);
394
- }
395
-
396
- export async function wuPruneTool(input: unknown): Promise<ToolOutput> {
397
- const parsed = toRecord(input);
398
- const args: string[] = [];
399
- if (parsed.execute === true) {
400
- args.push('--execute');
401
- }
402
-
403
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_PRUNE, args);
404
- }
405
-
406
- export async function wuDeleteTool(input: unknown): Promise<ToolOutput> {
407
- const parsed = toRecord(input);
408
- const id = toStringValue(parsed.id);
409
- const batch = toStringValue(parsed.batch);
410
- if (!id && !batch) {
411
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
412
- }
413
-
414
- const args: string[] = [];
415
- if (id) {
416
- args.push('--id', id);
417
- }
418
- if (parsed.dry_run === true) {
419
- args.push('--dry-run');
420
- }
421
- if (batch) {
422
- args.push('--batch', batch);
423
- }
424
-
425
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_DELETE, args);
426
- }
427
-
428
- export async function wuCleanupTool(input: unknown): Promise<ToolOutput> {
429
- const parsed = toRecord(input);
430
- const id = toStringValue(parsed.id);
431
- if (!id) {
432
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
433
- }
434
-
435
- const args: string[] = ['--id', id];
436
- if (parsed.artifacts === true) {
437
- args.push('--artifacts');
438
- }
439
-
440
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_CLEANUP, args);
441
- }
442
-
443
- export async function wuUnlockLaneTool(input: unknown): Promise<ToolOutput> {
444
- const parsed = toRecord(input);
445
- const listMode = parsed.list === true;
446
- const lane = toStringValue(parsed.lane);
447
- if (!listMode && !lane) {
448
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.LANE_REQUIRED);
449
- }
450
-
451
- const args: string[] = [];
452
- if (lane) {
453
- args.push('--lane', lane);
454
- }
455
- const reason = toStringValue(parsed.reason);
456
- if (reason) {
457
- args.push('--reason', reason);
458
- }
459
- if (parsed.force === true) {
460
- args.push('--force');
461
- }
462
- if (listMode) {
463
- args.push('--list');
464
- }
465
- if (parsed.status === true) {
466
- args.push('--status');
467
- }
468
-
469
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_UNLOCK_LANE, args);
470
- }
471
-
472
- export async function wuProtoTool(input: unknown): Promise<ToolOutput> {
473
- const parsed = toRecord(input);
474
- const lane = toStringValue(parsed.lane);
475
- const title = toStringValue(parsed.title);
476
- if (!lane) {
477
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.LANE_REQUIRED);
478
- }
479
- if (!title) {
480
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.TITLE_REQUIRED);
481
- }
482
-
483
- const args: string[] = ['--lane', lane, '--title', title];
484
- const description = toStringValue(parsed.description);
485
- if (description) {
486
- args.push(LIFECYCLE_FLAGS.DESCRIPTION, description);
487
- }
488
- pushRepeatedFlag(args, LIFECYCLE_FLAGS.CODE_PATHS, toStringArray(parsed.code_paths));
489
- const labels = toStringArray(parsed.labels);
490
- if (labels.length > 0) {
491
- args.push('--labels', labels.join(','));
492
- }
493
- const assignedTo = toStringValue(parsed.assigned_to);
494
- if (assignedTo) {
495
- args.push('--assigned-to', assignedTo);
496
- }
497
-
498
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_PROTO, args);
499
- }
500
-
501
- export async function wuBriefTool(input: unknown): Promise<ToolOutput> {
502
- const parsed = toRecord(input);
503
- const id = toStringValue(parsed.id);
504
- if (!id) {
505
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
506
- }
507
-
508
- const args: string[] = ['--id', id];
509
- appendWuPromptArgs(parsed, args);
510
-
511
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_BRIEF, args);
512
- }
513
-
514
- export async function wuDelegateTool(input: unknown): Promise<ToolOutput> {
515
- const parsed = toRecord(input);
516
- const id = toStringValue(parsed.id);
517
- const parentWu = toStringValue(parsed.parent_wu);
518
- if (!id) {
519
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
520
- }
521
- if (!parentWu) {
522
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.PARENT_WU_REQUIRED);
523
- }
524
-
525
- const args: string[] = ['--id', id];
526
- appendWuPromptArgs(parsed, args);
527
-
528
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_DELEGATE, args);
529
- }
530
-
531
- export async function wuDepsTool(input: unknown): Promise<ToolOutput> {
532
- const parsed = toRecord(input);
533
- const id = toStringValue(parsed.id);
534
- if (!id) {
535
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
536
- }
537
-
538
- const args: string[] = ['--id', id];
539
- const format = toStringValue(parsed.format);
540
- if (format) {
541
- args.push('--format', format);
542
- }
543
- const depth = toIntegerString(parsed.depth);
544
- if (depth) {
545
- args.push('--depth', depth);
546
- }
547
- const direction = toStringValue(parsed.direction);
548
- if (direction) {
549
- args.push('--direction', direction);
550
- }
551
-
552
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_DEPS, args);
553
- }
554
-
555
- export async function wuEditTool(input: unknown): Promise<ToolOutput> {
556
- const parsed = toRecord(input);
557
- const id = toStringValue(parsed.id);
558
- if (!id) {
559
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
560
- }
561
-
562
- const args: string[] = ['--id', id];
563
- const description = toStringValue(parsed.description);
564
- if (description) {
565
- args.push(LIFECYCLE_FLAGS.DESCRIPTION, description);
566
- }
567
- pushRepeatedFlag(args, '--acceptance', toStringArray(parsed.acceptance));
568
- const notes = toStringValue(parsed.notes);
569
- if (notes) {
570
- args.push('--notes', notes);
571
- }
572
- pushRepeatedFlag(args, LIFECYCLE_FLAGS.CODE_PATHS, toStringArray(parsed.code_paths));
573
- const lane = toStringValue(parsed.lane);
574
- if (lane) {
575
- args.push('--lane', lane);
576
- }
577
- const priority = toStringValue(parsed.priority);
578
- if (priority) {
579
- args.push('--priority', priority);
580
- }
581
- const initiative = toStringValue(parsed.initiative);
582
- if (initiative) {
583
- args.push('--initiative', initiative);
584
- }
585
- const phase = toIntegerString(parsed.phase);
586
- if (phase) {
587
- args.push('--phase', phase);
588
- }
589
- if (parsed.no_strict === true) {
590
- args.push('--no-strict');
591
- }
592
-
593
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_EDIT, args);
594
- }
595
-
596
- export async function wuBlockTool(input: unknown): Promise<ToolOutput> {
597
- const parsed = toRecord(input);
598
- const id = toStringValue(parsed.id);
599
- const reason = toStringValue(parsed.reason);
600
- if (!id) {
601
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
602
- }
603
- if (!reason) {
604
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.REASON_REQUIRED);
605
- }
606
-
607
- const args = ['--id', id, '--reason', reason];
608
- if (parsed.remove_worktree === true) {
609
- args.push('--remove-worktree');
610
- }
611
-
612
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_BLOCK, args);
613
- }
614
-
615
- export async function wuUnblockTool(input: unknown): Promise<ToolOutput> {
616
- const parsed = toRecord(input);
617
- const id = toStringValue(parsed.id);
618
- if (!id) {
619
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
620
- }
621
-
622
- const args = ['--id', id];
623
- const reason = toStringValue(parsed.reason);
624
- if (reason) {
625
- args.push('--reason', reason);
626
- }
627
- if (parsed.create_worktree === true) {
628
- args.push('--create-worktree');
629
- }
630
-
631
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_UNBLOCK, args);
632
- }
633
-
634
- export async function wuReleaseTool(input: unknown): Promise<ToolOutput> {
635
- const parsed = toRecord(input);
636
- const id = toStringValue(parsed.id);
637
- if (!id) {
638
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
639
- }
640
-
641
- const args = ['--id', id];
642
- const reason = toStringValue(parsed.reason);
643
- if (reason) {
644
- args.push('--reason', reason);
645
- }
646
-
647
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_RELEASE, args);
648
- }
649
-
650
- export async function wuRecoverTool(input: unknown): Promise<ToolOutput> {
651
- const parsed = toRecord(input);
652
- const id = toStringValue(parsed.id);
653
- if (!id) {
654
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
655
- }
656
-
657
- const args = ['--id', id];
658
- const action = toStringValue(parsed.action);
659
- if (action) {
660
- args.push('--action', action);
661
- }
662
- if (parsed.force === true) {
663
- args.push('--force');
664
- }
665
- if (parsed.json === true) {
666
- args.push('--json');
667
- }
668
-
669
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_RECOVER, args, {
670
- parseJson: parsed.json === true,
671
- });
672
- }
673
-
674
- export async function wuRepairTool(input: unknown): Promise<ToolOutput> {
675
- const parsed = toRecord(input);
676
-
677
- const args: string[] = [];
678
- const id = toStringValue(parsed.id);
679
- if (id) {
680
- args.push('--id', id);
681
- }
682
- if (parsed.check === true) {
683
- args.push('--check');
684
- }
685
- if (parsed.all === true) {
686
- args.push('--all');
687
- }
688
- if (parsed.claim === true) {
689
- args.push('--claim');
690
- }
691
- if (parsed.admin === true) {
692
- args.push('--admin');
693
- }
694
- if (parsed.repair_state === true) {
695
- args.push('--repair-state');
696
- }
697
-
698
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_REPAIR, args);
699
- }
700
-
701
- /**
702
- * WU-2833 (INIT-062 WU-G): privileged wu:repair variant registered as a
703
- * distinct pack tool (wu:repair:admin) so cloud-team phone UX can expose
704
- * admin recovery behind a remote_mutation approval gate without widening
705
- * the default wu:repair surface. Forces `--admin` on every invocation.
706
- */
707
- export async function wuRepairAdminTool(input: unknown): Promise<ToolOutput> {
708
- const parsed = toRecord(input);
709
-
710
- const args: string[] = ['--admin'];
711
- const id = toStringValue(parsed.id);
712
- if (id) {
713
- args.push('--id', id);
714
- }
715
- if (parsed.check === true) {
716
- args.push('--check');
717
- }
718
- if (parsed.all === true) {
719
- args.push('--all');
720
- }
721
- if (parsed.claim === true) {
722
- args.push('--claim');
723
- }
724
- if (parsed.repair_state === true) {
725
- args.push('--repair-state');
726
- }
727
-
728
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_REPAIR, args);
729
- }
730
-
731
- export async function wuStatusTool(input: unknown): Promise<ToolOutput> {
732
- const parsed = toRecord(input);
733
- const id = toStringValue(parsed.id);
734
- if (!id) {
735
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
736
- }
737
-
738
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_STATUS, ['--id', id, '--json'], {
739
- parseJson: true,
740
- });
741
- }
742
-
743
- export async function wuPreflightTool(input: unknown): Promise<ToolOutput> {
744
- const parsed = toRecord(input);
745
- const id = toStringValue(parsed.id);
746
- if (!id) {
747
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
748
- }
749
-
750
- const args = ['--id', id];
751
- const worktree = toStringValue(parsed.worktree);
752
- if (worktree) {
753
- args.push('--worktree', worktree);
754
- }
755
-
756
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_PREFLIGHT, args);
757
- }
758
-
759
- export async function wuValidateTool(input: unknown): Promise<ToolOutput> {
760
- const parsed = toRecord(input);
761
- const id = toStringValue(parsed.id);
762
- if (!id) {
763
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.ID_REQUIRED);
764
- }
765
-
766
- const args = ['--id', id];
767
- if (parsed.no_strict === true) {
768
- args.push('--no-strict');
769
- }
770
-
771
- return executeLifecycleTool(LIFECYCLE_TOOLS.WU_VALIDATE, args);
772
- }
773
-
774
- export async function gatesTool(input: unknown): Promise<ToolOutput> {
775
- const parsed = toRecord(input);
776
- const args: string[] = [];
777
- if (parsed.docs_only === true) {
778
- args.push('--docs-only');
779
- }
780
- if (parsed.full_lint === true) {
781
- args.push('--full-lint');
782
- }
783
- const coverageMode = toStringValue(parsed.coverage_mode);
784
- if (coverageMode) {
785
- args.push('--coverage-mode', coverageMode);
786
- }
787
-
788
- return executeLifecycleTool(LIFECYCLE_TOOLS.GATES, args);
789
- }
790
-
791
- /**
792
- * WU-2729 (INIT-060 Phase 2, ADR-013 §3 tool exposure): gates:docs is the
793
- * remote-callable tool that always runs docs-only gates. It exists as a
794
- * distinct manifest entry so the conductor scope grammar
795
- * (`tool:gates:docs`) can authorize it independently of the permissive
796
- * `gates` handler. Input `full_lint` and `coverage_mode` are forwarded
797
- * unchanged; `docs_only` is forced to true regardless of the caller's
798
- * input so there is no way to mis-dispatch a full gate run under this
799
- * tool name.
800
- */
801
- export async function gatesDocsTool(input: unknown): Promise<ToolOutput> {
802
- const parsed = toRecord(input);
803
- return gatesTool({
804
- ...parsed,
805
- docs_only: true,
806
- });
807
- }