@lumenflow/cli 5.4.0 → 5.7.12

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 (227) hide show
  1. package/README.md +42 -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/gate-defaults.js +191 -9
  7. package/dist/gate-defaults.js.map +1 -1
  8. package/dist/gate-registry.js.map +1 -1
  9. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  10. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  11. package/dist/gates/prod-migration-drift.js +207 -0
  12. package/dist/gates/prod-migration-drift.js.map +1 -0
  13. package/dist/gates/test-over-deletion-guard.js +255 -0
  14. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  15. package/dist/gates-runners.js +401 -2
  16. package/dist/gates-runners.js.map +1 -1
  17. package/dist/gates.js +349 -4
  18. package/dist/gates.js.map +1 -1
  19. package/dist/lumenflow-setup.js +144 -0
  20. package/dist/lumenflow-setup.js.map +1 -0
  21. package/dist/lumenflow-upgrade.js +2 -1
  22. package/dist/lumenflow-upgrade.js.map +1 -1
  23. package/dist/mem-create.js +10 -1
  24. package/dist/mem-create.js.map +1 -1
  25. package/dist/mem-signal.js +21 -4
  26. package/dist/mem-signal.js.map +1 -1
  27. package/dist/metrics-cli.js +19 -2
  28. package/dist/metrics-cli.js.map +1 -1
  29. package/dist/metrics-snapshot.js +25 -2
  30. package/dist/metrics-snapshot.js.map +1 -1
  31. package/dist/orchestrate-initiative.js +28 -3
  32. package/dist/orchestrate-initiative.js.map +1 -1
  33. package/dist/public-manifest.js +17 -0
  34. package/dist/public-manifest.js.map +1 -1
  35. package/dist/release.js +53 -18
  36. package/dist/release.js.map +1 -1
  37. package/dist/wu-done-gates.js +121 -8
  38. package/dist/wu-done-gates.js.map +1 -1
  39. package/dist/wu-done.js +30 -6
  40. package/dist/wu-done.js.map +1 -1
  41. package/dist/wu-edit-operations.js +74 -0
  42. package/dist/wu-edit-operations.js.map +1 -1
  43. package/dist/wu-edit-validators.js +58 -0
  44. package/dist/wu-edit-validators.js.map +1 -1
  45. package/dist/wu-edit.js +106 -4
  46. package/dist/wu-edit.js.map +1 -1
  47. package/dist/wu-prep.js +132 -8
  48. package/dist/wu-prep.js.map +1 -1
  49. package/dist/wu-recover.js +6 -0
  50. package/dist/wu-recover.js.map +1 -1
  51. package/dist/wu-release.js +120 -2
  52. package/dist/wu-release.js.map +1 -1
  53. package/dist/wu-sizing-validation.js +47 -17
  54. package/dist/wu-sizing-validation.js.map +1 -1
  55. package/dist/wu-status.js +33 -0
  56. package/dist/wu-status.js.map +1 -1
  57. package/package.json +13 -11
  58. package/packs/agent-runtime/package.json +1 -1
  59. package/packs/sidekick/package.json +1 -1
  60. package/packs/software-delivery/package.json +1 -1
  61. package/templates/core/AGENTS.md.template +162 -26
  62. package/templates/core/LUMENFLOW.md.template +381 -70
  63. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +0 -5
  64. package/templates/core/ai/onboarding/agent-safety-card.md.template +63 -17
  65. package/templates/core/ai/onboarding/initiative-orchestration.md.template +4 -0
  66. package/templates/core/ai/onboarding/release-process.md.template +7 -7
  67. package/templates/core/ai/onboarding/vendor-support.md.template +74 -10
  68. package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +1 -1
  69. package/templates/vendors/claude/.claude/skills/wu-lifecycle/SKILL.md.template +28 -0
  70. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  71. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  72. package/packs/agent-runtime/capability-factory.ts +0 -104
  73. package/packs/agent-runtime/constants.ts +0 -21
  74. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  75. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  76. package/packs/agent-runtime/delegation-tree.ts +0 -328
  77. package/packs/agent-runtime/index.ts +0 -20
  78. package/packs/agent-runtime/manifest.ts +0 -348
  79. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  80. package/packs/agent-runtime/orchestration.ts +0 -2027
  81. package/packs/agent-runtime/pack-registration.ts +0 -110
  82. package/packs/agent-runtime/policy-factory.ts +0 -165
  83. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  84. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  85. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  86. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  87. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  88. package/packs/agent-runtime/session-schema.ts +0 -467
  89. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  90. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  91. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  92. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  93. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  94. package/packs/agent-runtime/tools/index.ts +0 -4
  95. package/packs/agent-runtime/tools/types.ts +0 -47
  96. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  97. package/packs/agent-runtime/types.ts +0 -128
  98. package/packs/agent-runtime/vitest.config.ts +0 -11
  99. package/packs/sidekick/channel-ingress.ts +0 -137
  100. package/packs/sidekick/constants.ts +0 -10
  101. package/packs/sidekick/index.ts +0 -8
  102. package/packs/sidekick/manifest-schema.ts +0 -49
  103. package/packs/sidekick/manifest.ts +0 -512
  104. package/packs/sidekick/pack-registration.ts +0 -110
  105. package/packs/sidekick/policy-factory.ts +0 -38
  106. package/packs/sidekick/sidekick-events.ts +0 -694
  107. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  108. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  109. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  110. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  111. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  112. package/packs/sidekick/src/routines/commit.ts +0 -74
  113. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  114. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  115. package/packs/sidekick/tool-impl/index.ts +0 -29
  116. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  117. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  118. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  119. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  120. package/packs/sidekick/tool-impl/shared.ts +0 -125
  121. package/packs/sidekick/tool-impl/storage.ts +0 -325
  122. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  123. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  124. package/packs/sidekick/tools/channel-tools.ts +0 -53
  125. package/packs/sidekick/tools/index.ts +0 -9
  126. package/packs/sidekick/tools/memory-tools.ts +0 -53
  127. package/packs/sidekick/tools/routine-tools.ts +0 -53
  128. package/packs/sidekick/tools/system-tools.ts +0 -47
  129. package/packs/sidekick/tools/task-tools.ts +0 -61
  130. package/packs/sidekick/tools/types.ts +0 -57
  131. package/packs/sidekick/vitest.config.ts +0 -11
  132. package/packs/software-delivery/constants.ts +0 -10
  133. package/packs/software-delivery/extensions.ts +0 -140
  134. package/packs/software-delivery/gate-policies.ts +0 -134
  135. package/packs/software-delivery/index.ts +0 -8
  136. package/packs/software-delivery/manifest-schema.ts +0 -268
  137. package/packs/software-delivery/manifest.ts +0 -657
  138. package/packs/software-delivery/pack-registration.ts +0 -113
  139. package/packs/software-delivery/src/commands/index.ts +0 -5
  140. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  141. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  142. package/packs/software-delivery/src/config/index.ts +0 -8
  143. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  144. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  145. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  146. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  147. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  148. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  149. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  150. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  151. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  152. package/packs/software-delivery/src/constants/index.ts +0 -29
  153. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  154. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  155. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  156. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -488
  157. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  158. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  159. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  160. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  161. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  162. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  163. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  164. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  165. package/packs/software-delivery/src/domain/index.ts +0 -5
  166. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  167. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  168. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  169. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  170. package/packs/software-delivery/src/methodology/index.ts +0 -6
  171. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  172. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  173. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  174. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  175. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  176. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  177. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  178. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  179. package/packs/software-delivery/src/policy/index.ts +0 -22
  180. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  181. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  182. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  183. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  184. package/packs/software-delivery/src/ports/index.ts +0 -10
  185. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  186. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  187. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  188. package/packs/software-delivery/src/primitives/index.ts +0 -5
  189. package/packs/software-delivery/src/runtime/index.ts +0 -6
  190. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  191. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  192. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  193. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  194. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  195. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  196. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  197. package/packs/software-delivery/src/schemas/index.ts +0 -5
  198. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  199. package/packs/software-delivery/src/state/index.ts +0 -15
  200. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  201. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  202. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  203. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  204. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  205. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  206. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  207. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  208. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  209. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  210. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  211. package/packs/software-delivery/tool-impl/index.ts +0 -15
  212. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  213. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  214. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  215. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  216. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  217. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  218. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  219. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  220. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  221. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  222. package/packs/software-delivery/tools/git-tools.ts +0 -55
  223. package/packs/software-delivery/tools/index.ts +0 -8
  224. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  225. package/packs/software-delivery/tools/types.ts +0 -71
  226. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  227. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,263 +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 AGENT_TOOLS = {
8
- AGENT_SESSION: 'agent:session',
9
- AGENT_SESSION_END: 'agent:session-end',
10
- AGENT_LOG_ISSUE: 'agent:log-issue',
11
- AGENT_ISSUES_QUERY: 'agent:issues-query',
12
- } as const;
13
-
14
- type AgentToolName = (typeof AGENT_TOOLS)[keyof typeof AGENT_TOOLS];
15
-
16
- const AGENT_TOOL_ERROR_CODES: Record<AgentToolName, string> = {
17
- 'agent:session': 'AGENT_SESSION_ERROR',
18
- 'agent:session-end': 'AGENT_SESSION_END_ERROR',
19
- 'agent:log-issue': 'AGENT_LOG_ISSUE_ERROR',
20
- 'agent:issues-query': 'AGENT_ISSUES_QUERY_ERROR',
21
- };
22
-
23
- const AGENT_TOOL_COMMANDS: Record<
24
- AgentToolName,
25
- (typeof RUNTIME_CLI_COMMANDS)[keyof typeof RUNTIME_CLI_COMMANDS]
26
- > = {
27
- 'agent:session': RUNTIME_CLI_COMMANDS.AGENT_SESSION,
28
- 'agent:session-end': RUNTIME_CLI_COMMANDS.AGENT_SESSION_END,
29
- 'agent:log-issue': RUNTIME_CLI_COMMANDS.AGENT_LOG_ISSUE,
30
- 'agent:issues-query': RUNTIME_CLI_COMMANDS.AGENT_ISSUES_QUERY,
31
- };
32
-
33
- const MISSING_PARAMETER_MESSAGES = {
34
- WU_REQUIRED: 'wu is required',
35
- TIER_REQUIRED: 'tier is required',
36
- CATEGORY_REQUIRED: 'category is required',
37
- SEVERITY_REQUIRED: 'severity is required',
38
- TITLE_REQUIRED: 'title is required',
39
- DESCRIPTION_REQUIRED: 'description is required',
40
- } as const;
41
-
42
- interface CommandExecutionResult {
43
- ok: boolean;
44
- status: number;
45
- stdout: string;
46
- stderr: string;
47
- executionError?: string;
48
- }
49
-
50
- function toRecord(input: unknown): Record<string, unknown> {
51
- if (input && typeof input === 'object') {
52
- return input as Record<string, unknown>;
53
- }
54
- return {};
55
- }
56
-
57
- function toStringValue(value: unknown): string | null {
58
- if (typeof value !== 'string') {
59
- return null;
60
- }
61
- const trimmed = value.trim();
62
- return trimmed.length > 0 ? trimmed : null;
63
- }
64
-
65
- function toStringArray(value: unknown): string[] {
66
- if (!Array.isArray(value)) {
67
- return [];
68
- }
69
- return value
70
- .map((entry) => toStringValue(entry))
71
- .filter((entry): entry is string => entry !== null);
72
- }
73
-
74
- function toIntegerString(value: unknown): string | null {
75
- if (typeof value === 'number' && Number.isFinite(value)) {
76
- return String(Math.trunc(value));
77
- }
78
- if (typeof value === 'string') {
79
- const trimmed = value.trim();
80
- return trimmed.length > 0 ? trimmed : null;
81
- }
82
- return null;
83
- }
84
-
85
- async function runAgentCommand(
86
- toolName: AgentToolName,
87
- args: string[],
88
- ): Promise<CommandExecutionResult> {
89
- return runtimeCliAdapter.run(AGENT_TOOL_COMMANDS[toolName], args);
90
- }
91
-
92
- function createMissingParameterOutput(message: string): ToolOutput {
93
- return {
94
- success: false,
95
- error: {
96
- code: 'MISSING_PARAMETER',
97
- message,
98
- },
99
- };
100
- }
101
-
102
- function createFailureOutput(
103
- toolName: AgentToolName,
104
- execution: CommandExecutionResult,
105
- ): ToolOutput {
106
- const stderrMessage = execution.stderr.trim();
107
- const stdoutMessage = execution.stdout.trim();
108
- const message =
109
- execution.executionError ??
110
- (stderrMessage.length > 0
111
- ? stderrMessage
112
- : stdoutMessage.length > 0
113
- ? stdoutMessage
114
- : `${toolName} failed`);
115
- return {
116
- success: false,
117
- error: {
118
- code: AGENT_TOOL_ERROR_CODES[toolName],
119
- message,
120
- details: {
121
- exit_code: execution.status,
122
- stdout: execution.stdout,
123
- stderr: execution.stderr,
124
- },
125
- },
126
- };
127
- }
128
-
129
- function parseJsonOutput(stdout: string): unknown | null {
130
- const trimmed = stdout.trim();
131
- if (trimmed.length === 0) {
132
- return null;
133
- }
134
- try {
135
- return JSON.parse(trimmed) as unknown;
136
- } catch {
137
- return null;
138
- }
139
- }
140
-
141
- function createSuccessOutput(
142
- toolName: AgentToolName,
143
- execution: CommandExecutionResult,
144
- ): ToolOutput {
145
- const parsedJson = parseJsonOutput(execution.stdout);
146
- if (parsedJson !== null) {
147
- return {
148
- success: true,
149
- data: parsedJson,
150
- };
151
- }
152
-
153
- const message = execution.stdout.trim().length > 0 ? execution.stdout.trim() : `${toolName} ran`;
154
- return {
155
- success: true,
156
- data: {
157
- message,
158
- },
159
- };
160
- }
161
-
162
- async function executeAgentTool(toolName: AgentToolName, args: string[]): Promise<ToolOutput> {
163
- const execution = await runAgentCommand(toolName, args);
164
- if (!execution.ok) {
165
- return createFailureOutput(toolName, execution);
166
- }
167
- return createSuccessOutput(toolName, execution);
168
- }
169
-
170
- export async function agentSessionTool(input: unknown): Promise<ToolOutput> {
171
- const parsed = toRecord(input);
172
- const wu = toStringValue(parsed.wu);
173
- if (!wu) {
174
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.WU_REQUIRED);
175
- }
176
-
177
- const tier = toIntegerString(parsed.tier);
178
- if (!tier) {
179
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.TIER_REQUIRED);
180
- }
181
-
182
- const args = ['--wu', wu, '--tier', tier];
183
- const agentType = toStringValue(parsed.agent_type);
184
- if (agentType) {
185
- args.push('--agent-type', agentType);
186
- }
187
-
188
- return executeAgentTool(AGENT_TOOLS.AGENT_SESSION, args);
189
- }
190
-
191
- export async function agentSessionEndTool(_input: unknown): Promise<ToolOutput> {
192
- return executeAgentTool(AGENT_TOOLS.AGENT_SESSION_END, []);
193
- }
194
-
195
- export async function agentLogIssueTool(input: unknown): Promise<ToolOutput> {
196
- const parsed = toRecord(input);
197
- const category = toStringValue(parsed.category);
198
- if (!category) {
199
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.CATEGORY_REQUIRED);
200
- }
201
- const severity = toStringValue(parsed.severity);
202
- if (!severity) {
203
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.SEVERITY_REQUIRED);
204
- }
205
- const title = toStringValue(parsed.title);
206
- if (!title) {
207
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.TITLE_REQUIRED);
208
- }
209
- const description = toStringValue(parsed.description);
210
- if (!description) {
211
- return createMissingParameterOutput(MISSING_PARAMETER_MESSAGES.DESCRIPTION_REQUIRED);
212
- }
213
-
214
- const args = [
215
- '--category',
216
- category,
217
- '--severity',
218
- severity,
219
- '--title',
220
- title,
221
- '--description',
222
- description,
223
- ];
224
- const resolution = toStringValue(parsed.resolution);
225
- if (resolution) {
226
- args.push('--resolution', resolution);
227
- }
228
-
229
- for (const tag of toStringArray(parsed.tags)) {
230
- args.push('--tag', tag);
231
- }
232
-
233
- const step = toStringValue(parsed.step);
234
- if (step) {
235
- args.push('--step', step);
236
- }
237
-
238
- for (const file of toStringArray(parsed.files)) {
239
- args.push('--file', file);
240
- }
241
-
242
- return executeAgentTool(AGENT_TOOLS.AGENT_LOG_ISSUE, args);
243
- }
244
-
245
- export async function agentIssuesQueryTool(input: unknown): Promise<ToolOutput> {
246
- const parsed = toRecord(input);
247
- const args = ['summary'];
248
-
249
- const since = toIntegerString(parsed.since);
250
- if (since) {
251
- args.push('--since', since);
252
- }
253
- const category = toStringValue(parsed.category);
254
- if (category) {
255
- args.push('--category', category);
256
- }
257
- const severity = toStringValue(parsed.severity);
258
- if (severity) {
259
- args.push('--severity', severity);
260
- }
261
-
262
- return executeAgentTool(AGENT_TOOLS.AGENT_ISSUES_QUERY, args);
263
- }
@@ -1,66 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /* eslint-disable security/detect-non-literal-fs-filename */
5
- import { appendFile, mkdir } from 'node:fs/promises';
6
- import path from 'node:path';
7
- import { UTF8_ENCODING } from '../constants.js';
8
-
9
- export interface RecordDelegationInput {
10
- parentWuId: string;
11
- targetWuId: string;
12
- lane: string;
13
- registryPath: string;
14
- lineage?: string[];
15
- }
16
-
17
- export interface RecordDelegationResult {
18
- success: boolean;
19
- delegationId: string;
20
- }
21
-
22
- function migrateLegacyStatePath(registryPath: string): string {
23
- const normalized = registryPath.replace(/\\/g, '/');
24
- if (normalized.startsWith('.lumenflow/state/')) {
25
- return path.join('runtime', 'state', normalized.slice('.lumenflow/state/'.length));
26
- }
27
-
28
- const legacySegment = '/.lumenflow/state/';
29
- const segmentIndex = normalized.indexOf(legacySegment);
30
- if (segmentIndex < 0) {
31
- return registryPath;
32
- }
33
-
34
- return [
35
- normalized.slice(0, segmentIndex),
36
- 'runtime',
37
- 'state',
38
- normalized.slice(segmentIndex + legacySegment.length),
39
- ]
40
- .filter(Boolean)
41
- .join('/');
42
- }
43
-
44
- export async function recordDelegationTool(
45
- input: RecordDelegationInput,
46
- ): Promise<RecordDelegationResult> {
47
- const registryPath = migrateLegacyStatePath(input.registryPath);
48
- const delegationId = `dlg-${input.parentWuId.toLowerCase()}-${input.targetWuId.toLowerCase()}`;
49
- const entry = {
50
- id: delegationId,
51
- parentWuId: input.parentWuId,
52
- targetWuId: input.targetWuId,
53
- lane: input.lane,
54
- lineage: input.lineage ?? [],
55
- delegatedAt: new Date().toISOString(),
56
- status: 'pending',
57
- };
58
-
59
- await mkdir(path.dirname(registryPath), { recursive: true });
60
- await appendFile(registryPath, `${JSON.stringify(entry)}\n`, UTF8_ENCODING);
61
-
62
- return {
63
- success: true,
64
- delegationId,
65
- };
66
- }
@@ -1,219 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * @file flow-metrics-tools.ts
6
- * @description Software-delivery pack handlers for flow/metrics tools.
7
- *
8
- * WU-1905: Migrated from in-process resolver stubs in runtime-tool-resolver.ts
9
- * to native software-delivery pack handlers.
10
- */
11
-
12
- import type { ToolOutput } from '@lumenflow/kernel';
13
- import { RUNTIME_CLI_COMMANDS, runtimeCliAdapter } from './runtime-cli-adapter.js';
14
-
15
- // --- Tool name constants ---
16
-
17
- const FLOW_METRICS_TOOLS = {
18
- FLOW_BOTTLENECKS: 'flow:bottlenecks',
19
- FLOW_REPORT: 'flow:report',
20
- METRICS: 'metrics',
21
- METRICS_SNAPSHOT: 'metrics:snapshot',
22
- } as const;
23
-
24
- type FlowMetricsToolName = (typeof FLOW_METRICS_TOOLS)[keyof typeof FLOW_METRICS_TOOLS];
25
-
26
- // --- Error code mapping ---
27
-
28
- const FLOW_METRICS_TOOL_ERROR_CODES: Record<FlowMetricsToolName, string> = {
29
- 'flow:bottlenecks': 'FLOW_BOTTLENECKS_ERROR',
30
- 'flow:report': 'FLOW_REPORT_ERROR',
31
- metrics: 'METRICS_ERROR',
32
- 'metrics:snapshot': 'METRICS_SNAPSHOT_ERROR',
33
- };
34
-
35
- const FLOW_METRICS_TOOL_COMMANDS: Record<
36
- FlowMetricsToolName,
37
- (typeof RUNTIME_CLI_COMMANDS)[keyof typeof RUNTIME_CLI_COMMANDS]
38
- > = {
39
- 'flow:bottlenecks': RUNTIME_CLI_COMMANDS.FLOW_BOTTLENECKS,
40
- 'flow:report': RUNTIME_CLI_COMMANDS.FLOW_REPORT,
41
- metrics: RUNTIME_CLI_COMMANDS.METRICS,
42
- 'metrics:snapshot': RUNTIME_CLI_COMMANDS.METRICS_SNAPSHOT,
43
- };
44
-
45
- // --- Input helpers ---
46
-
47
- function toRecord(input: unknown): Record<string, unknown> {
48
- if (input && typeof input === 'object') {
49
- return input as Record<string, unknown>;
50
- }
51
- return {};
52
- }
53
-
54
- function toStringValue(value: unknown): string | null {
55
- if (typeof value !== 'string') {
56
- return null;
57
- }
58
- const trimmed = value.trim();
59
- return trimmed.length > 0 ? trimmed : null;
60
- }
61
-
62
- function toNumberValue(value: unknown): number | null {
63
- if (typeof value === 'number' && Number.isFinite(value)) {
64
- return value;
65
- }
66
- return null;
67
- }
68
-
69
- // --- Command execution ---
70
-
71
- interface CommandExecutionResult {
72
- ok: boolean;
73
- status: number;
74
- stdout: string;
75
- stderr: string;
76
- executionError?: string;
77
- }
78
-
79
- async function runFlowMetricsCommand(
80
- toolName: FlowMetricsToolName,
81
- args: string[],
82
- ): Promise<CommandExecutionResult> {
83
- return runtimeCliAdapter.run(FLOW_METRICS_TOOL_COMMANDS[toolName], args);
84
- }
85
-
86
- function createFailureOutput(
87
- toolName: FlowMetricsToolName,
88
- execution: CommandExecutionResult,
89
- ): ToolOutput {
90
- const stderrMessage = execution.stderr.trim();
91
- const stdoutMessage = execution.stdout.trim();
92
- const message =
93
- execution.executionError ??
94
- (stderrMessage.length > 0
95
- ? stderrMessage
96
- : stdoutMessage.length > 0
97
- ? stdoutMessage
98
- : `${toolName} failed`);
99
- return {
100
- success: false,
101
- error: {
102
- code: FLOW_METRICS_TOOL_ERROR_CODES[toolName],
103
- message,
104
- details: {
105
- exit_code: execution.status,
106
- stdout: execution.stdout,
107
- stderr: execution.stderr,
108
- },
109
- },
110
- };
111
- }
112
-
113
- function createSuccessOutput(
114
- toolName: FlowMetricsToolName,
115
- execution: CommandExecutionResult,
116
- ): ToolOutput {
117
- const message = execution.stdout.trim().length > 0 ? execution.stdout.trim() : `${toolName} ran`;
118
- return {
119
- success: true,
120
- data: {
121
- message,
122
- },
123
- };
124
- }
125
-
126
- async function executeFlowMetricsTool(
127
- toolName: FlowMetricsToolName,
128
- args: string[],
129
- ): Promise<ToolOutput> {
130
- const execution = await runFlowMetricsCommand(toolName, args);
131
- if (!execution.ok) {
132
- return createFailureOutput(toolName, execution);
133
- }
134
- return createSuccessOutput(toolName, execution);
135
- }
136
-
137
- // --- Public tool handlers ---
138
-
139
- /**
140
- * flow:bottlenecks handler -- identifies flow bottlenecks via CLI.
141
- */
142
- export async function flowBottlenecksTool(input: unknown): Promise<ToolOutput> {
143
- const parsed = toRecord(input);
144
- const args: string[] = [];
145
-
146
- const limit = toNumberValue(parsed.limit);
147
- if (limit !== null) {
148
- args.push('--limit', String(limit));
149
- }
150
-
151
- const format = toStringValue(parsed.format);
152
- if (format) {
153
- args.push('--format', format);
154
- }
155
-
156
- return executeFlowMetricsTool(FLOW_METRICS_TOOLS.FLOW_BOTTLENECKS, args);
157
- }
158
-
159
- /**
160
- * flow:report handler -- generates flow metrics report via CLI.
161
- */
162
- export async function flowReportTool(input: unknown): Promise<ToolOutput> {
163
- const parsed = toRecord(input);
164
- const args: string[] = [];
165
-
166
- const start = toStringValue(parsed.start);
167
- if (start) {
168
- args.push('--start', start);
169
- }
170
-
171
- const end = toStringValue(parsed.end);
172
- if (end) {
173
- args.push('--end', end);
174
- }
175
-
176
- const days = toNumberValue(parsed.days);
177
- if (days !== null) {
178
- args.push('--days', String(days));
179
- }
180
-
181
- const format = toStringValue(parsed.format);
182
- if (format) {
183
- args.push('--format', format);
184
- }
185
-
186
- return executeFlowMetricsTool(FLOW_METRICS_TOOLS.FLOW_REPORT, args);
187
- }
188
-
189
- /**
190
- * metrics handler -- unified workflow metrics command via CLI.
191
- */
192
- export async function metricsTool(input: unknown): Promise<ToolOutput> {
193
- const parsed = toRecord(input);
194
- const args: string[] = [];
195
-
196
- const subcommand = toStringValue(parsed.subcommand);
197
- if (subcommand) {
198
- args.push(subcommand);
199
- }
200
-
201
- const days = toNumberValue(parsed.days);
202
- if (days !== null) {
203
- args.push('--days', String(days));
204
- }
205
-
206
- const format = toStringValue(parsed.format);
207
- if (format) {
208
- args.push('--format', format);
209
- }
210
-
211
- return executeFlowMetricsTool(FLOW_METRICS_TOOLS.METRICS, args);
212
- }
213
-
214
- /**
215
- * metrics:snapshot handler -- captures metrics snapshot via CLI.
216
- */
217
- export async function metricsSnapshotTool(_input: unknown): Promise<ToolOutput> {
218
- return executeFlowMetricsTool(FLOW_METRICS_TOOLS.METRICS_SNAPSHOT, []);
219
- }
@@ -1,113 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- import { execFileSync } from 'node:child_process';
5
- import { UTF8_ENCODING } from '../constants.js';
6
-
7
- const GIT_BINARY_ENV_VAR = 'LUMENFLOW_GIT_BINARY';
8
- const POSIX_GIT_BINARY = 'git';
9
- const WINDOWS_GIT_BINARY = 'git.exe';
10
-
11
- export interface GitCommandResult {
12
- ok: boolean;
13
- stdout: string;
14
- stderr: string;
15
- status: number;
16
- }
17
-
18
- function firstNonEmptyLine(value: unknown): string | null {
19
- if (typeof value !== 'string') {
20
- return null;
21
- }
22
- const line = value
23
- .split(/\r?\n/)
24
- .map((entry) => entry.trim())
25
- .find((entry) => entry.length > 0);
26
- return line ?? null;
27
- }
28
-
29
- function resolveGitBinaryFromPath(): string | null {
30
- const lookupCommand = process.platform === 'win32' ? 'where' : 'which';
31
- const lookupTarget = process.platform === 'win32' ? WINDOWS_GIT_BINARY : POSIX_GIT_BINARY;
32
- const lookupResult = runCommand(lookupCommand, [lookupTarget], {});
33
-
34
- if (!lookupResult || lookupResult.status !== 0) {
35
- return null;
36
- }
37
- return firstNonEmptyLine(lookupResult.stdout);
38
- }
39
-
40
- export function resolveGitBinary(): string {
41
- const configured = process.env[GIT_BINARY_ENV_VAR]?.trim();
42
- if (configured && configured.length > 0) {
43
- return configured;
44
- }
45
- const resolved = resolveGitBinaryFromPath();
46
- if (resolved) {
47
- return resolved;
48
- }
49
- return process.platform === 'win32' ? WINDOWS_GIT_BINARY : POSIX_GIT_BINARY;
50
- }
51
-
52
- export const GIT_BINARY = resolveGitBinary();
53
-
54
- export function runGit(
55
- args: string[],
56
- options: { cwd?: string; gitBinary?: string } = {},
57
- ): GitCommandResult {
58
- const result = runCommand(options.gitBinary ?? GIT_BINARY, args, { cwd: options.cwd });
59
- return {
60
- ok: result.status === 0,
61
- stdout: result.stdout,
62
- stderr: result.stderr,
63
- status: result.status ?? 1,
64
- };
65
- }
66
-
67
- function runCommand(command: string, args: string[], options: { cwd?: string }): GitCommandResult {
68
- try {
69
- const stdout = execFileSync(command, args, {
70
- cwd: options.cwd,
71
- encoding: UTF8_ENCODING,
72
- stdio: ['ignore', 'pipe', 'pipe'],
73
- });
74
- return {
75
- ok: true,
76
- stdout,
77
- stderr: '',
78
- status: 0,
79
- };
80
- } catch (error: unknown) {
81
- if (error && typeof error === 'object') {
82
- const typedError = error as {
83
- status?: number;
84
- stdout?: string | Buffer;
85
- stderr?: string | Buffer;
86
- message?: string;
87
- };
88
- return {
89
- ok: false,
90
- stdout: toCommandOutput(typedError.stdout),
91
- stderr: toCommandOutput(typedError.stderr) || (typedError.message ?? ''),
92
- status: typeof typedError.status === 'number' ? typedError.status : 1,
93
- };
94
- }
95
-
96
- return {
97
- ok: false,
98
- stdout: '',
99
- stderr: String(error),
100
- status: 1,
101
- };
102
- }
103
- }
104
-
105
- function toCommandOutput(value: string | Buffer | undefined): string {
106
- if (typeof value === 'string') {
107
- return value;
108
- }
109
- if (value instanceof Buffer) {
110
- return value.toString(UTF8_ENCODING);
111
- }
112
- return '';
113
- }