@lumenflow/cli 4.20.1 → 4.21.0

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 (127) hide show
  1. package/dist/config-set.js +54 -36
  2. package/dist/config-set.js.map +1 -1
  3. package/dist/gate-conditional.js +476 -0
  4. package/dist/gate-conditional.js.map +1 -0
  5. package/dist/initiative-add-wu.js +2 -2
  6. package/dist/initiative-add-wu.js.map +1 -1
  7. package/dist/initiative-create.js +42 -24
  8. package/dist/initiative-create.js.map +1 -1
  9. package/dist/initiative-delete.js +146 -0
  10. package/dist/initiative-delete.js.map +1 -0
  11. package/dist/initiative-edit.js +3 -3
  12. package/dist/initiative-edit.js.map +1 -1
  13. package/dist/initiative-plan.js +2 -2
  14. package/dist/initiative-plan.js.map +1 -1
  15. package/dist/initiative-remove-wu.js +2 -2
  16. package/dist/initiative-remove-wu.js.map +1 -1
  17. package/dist/initiative-rename.js +138 -0
  18. package/dist/initiative-rename.js.map +1 -0
  19. package/dist/public-manifest.js +21 -0
  20. package/dist/public-manifest.js.map +1 -1
  21. package/package.json +11 -8
  22. package/packs/agent-runtime/.turbo/turbo-build.log +1 -1
  23. package/packs/agent-runtime/package.json +1 -1
  24. package/packs/sidekick/.turbo/turbo-build.log +1 -1
  25. package/packs/sidekick/package.json +1 -1
  26. package/packs/software-delivery/.turbo/turbo-build.log +1 -1
  27. package/packs/software-delivery/package.json +1 -1
  28. package/templates/core/LUMENFLOW.md.template +1 -0
  29. package/templates/core/ai/onboarding/quick-ref-commands.md.template +4 -0
  30. package/dist/chunk-2D2VOCA4.js +0 -37
  31. package/dist/chunk-2D5KFYGX.js +0 -284
  32. package/dist/chunk-2GXVIN57.js +0 -14072
  33. package/dist/chunk-2MQ7HZWZ.js +0 -26
  34. package/dist/chunk-2UFQ3A3C.js +0 -643
  35. package/dist/chunk-3RG5ZIWI.js +0 -10
  36. package/dist/chunk-4N74J3UT.js +0 -15
  37. package/dist/chunk-5GTOXFYR.js +0 -392
  38. package/dist/chunk-5VY6MQMC.js +0 -240
  39. package/dist/chunk-67XVPMRY.js +0 -1297
  40. package/dist/chunk-6HO4GWJE.js +0 -164
  41. package/dist/chunk-6W5XHWYV.js +0 -1890
  42. package/dist/chunk-6X4EMYJQ.js +0 -64
  43. package/dist/chunk-6XYXI2NQ.js +0 -772
  44. package/dist/chunk-7ANSOV6Q.js +0 -285
  45. package/dist/chunk-A624LFLB.js +0 -1380
  46. package/dist/chunk-ADN5NHG4.js +0 -126
  47. package/dist/chunk-B7YJYJKG.js +0 -33
  48. package/dist/chunk-CCLHCPKG.js +0 -210
  49. package/dist/chunk-CK36VROC.js +0 -1584
  50. package/dist/chunk-D3UOFRSB.js +0 -81
  51. package/dist/chunk-DFR4DJBM.js +0 -230
  52. package/dist/chunk-DSYBDHYH.js +0 -79
  53. package/dist/chunk-DWMLTXKQ.js +0 -1176
  54. package/dist/chunk-E3REJTAJ.js +0 -28
  55. package/dist/chunk-EA3IVO64.js +0 -633
  56. package/dist/chunk-EK2AKZKD.js +0 -55
  57. package/dist/chunk-ELD7JTTT.js +0 -343
  58. package/dist/chunk-EX6TT2XI.js +0 -195
  59. package/dist/chunk-EXINSFZE.js +0 -82
  60. package/dist/chunk-EZ6ZBYBM.js +0 -510
  61. package/dist/chunk-FBKAPTJ2.js +0 -16
  62. package/dist/chunk-FVLV5RYH.js +0 -1118
  63. package/dist/chunk-GDNSBQVK.js +0 -2485
  64. package/dist/chunk-GPQHMBNN.js +0 -278
  65. package/dist/chunk-GTFJB67L.js +0 -68
  66. package/dist/chunk-HANJXVKW.js +0 -1127
  67. package/dist/chunk-HEVS5YLD.js +0 -269
  68. package/dist/chunk-HMEVZKPQ.js +0 -9
  69. package/dist/chunk-HRGSYNLM.js +0 -3511
  70. package/dist/chunk-ISZR5N4K.js +0 -60
  71. package/dist/chunk-J6SUPR2C.js +0 -226
  72. package/dist/chunk-JERYVEIZ.js +0 -244
  73. package/dist/chunk-JHHWGL2N.js +0 -87
  74. package/dist/chunk-JONWQUB5.js +0 -775
  75. package/dist/chunk-K2DIWWDM.js +0 -1766
  76. package/dist/chunk-KY4PGL5V.js +0 -969
  77. package/dist/chunk-L737LQ4C.js +0 -1285
  78. package/dist/chunk-LFTWYIB2.js +0 -497
  79. package/dist/chunk-LV47RFNJ.js +0 -41
  80. package/dist/chunk-MKSAITI7.js +0 -15
  81. package/dist/chunk-MZ7RKIX4.js +0 -212
  82. package/dist/chunk-NAP6CFSO.js +0 -84
  83. package/dist/chunk-ND6MY37M.js +0 -16
  84. package/dist/chunk-NMG736UR.js +0 -683
  85. package/dist/chunk-NRAXROED.js +0 -32
  86. package/dist/chunk-NRIZR3A7.js +0 -690
  87. package/dist/chunk-NX43BG3M.js +0 -233
  88. package/dist/chunk-O645XLSI.js +0 -297
  89. package/dist/chunk-OMJD6A3S.js +0 -235
  90. package/dist/chunk-QB6SJD4T.js +0 -430
  91. package/dist/chunk-QFSTL4J3.js +0 -276
  92. package/dist/chunk-QLGDFMFX.js +0 -212
  93. package/dist/chunk-RIAAGL2E.js +0 -13
  94. package/dist/chunk-RWO5XMZ6.js +0 -86
  95. package/dist/chunk-RXRKBBSM.js +0 -149
  96. package/dist/chunk-RZOZMML6.js +0 -363
  97. package/dist/chunk-U7I7FS7T.js +0 -113
  98. package/dist/chunk-UI42RODY.js +0 -717
  99. package/dist/chunk-UTVMVSCO.js +0 -519
  100. package/dist/chunk-V6OJGLBA.js +0 -1746
  101. package/dist/chunk-W2JHVH7D.js +0 -152
  102. package/dist/chunk-WD3Y7VQN.js +0 -280
  103. package/dist/chunk-WOCTQ5MS.js +0 -303
  104. package/dist/chunk-WZR3ZUNN.js +0 -696
  105. package/dist/chunk-XGI665H7.js +0 -150
  106. package/dist/chunk-XKY65P2T.js +0 -304
  107. package/dist/chunk-Y4CQZY65.js +0 -57
  108. package/dist/chunk-YFEXKLVE.js +0 -194
  109. package/dist/chunk-YHO3HS5X.js +0 -287
  110. package/dist/chunk-YLS7AZSX.js +0 -738
  111. package/dist/chunk-ZE473AO6.js +0 -49
  112. package/dist/chunk-ZF747T3O.js +0 -644
  113. package/dist/chunk-ZHCZHZH3.js +0 -43
  114. package/dist/chunk-ZZNZX2XY.js +0 -87
  115. package/dist/constants-7QAP3VQ4.js +0 -23
  116. package/dist/dist-IY3UUMWK.js +0 -33
  117. package/dist/invariants-runner-W5RGHCSU.js +0 -27
  118. package/dist/lane-lock-6J36HD5O.js +0 -35
  119. package/dist/mem-checkpoint-core-EANG2GVN.js +0 -14
  120. package/dist/mem-signal-core-2LZ2WYHW.js +0 -19
  121. package/dist/memory-store-OLB5FO7K.js +0 -18
  122. package/dist/service-6BYCOCO5.js +0 -13
  123. package/dist/spawn-policy-resolver-NTSZYQ6R.js +0 -17
  124. package/dist/spawn-task-builder-R4E2BHSW.js +0 -22
  125. package/dist/wu-done-pr-WLFFFEPJ.js +0 -25
  126. package/dist/wu-done-validation-3J5E36FE.js +0 -30
  127. package/dist/wu-duplicate-id-detector-5S7JHELK.js +0 -232
@@ -1,55 +0,0 @@
1
- // src/wu-lifecycle-sync/constants.ts
2
- var WU_LIFECYCLE_COMMANDS = {
3
- CREATE: "wu:create",
4
- CLAIM: "wu:claim",
5
- DONE: "wu:done"
6
- };
7
- var WU_LIFECYCLE_EVENT_KINDS = {
8
- CREATE: "task_created",
9
- CLAIM: "task_claimed",
10
- DONE: "task_completed"
11
- };
12
- var WU_LIFECYCLE_SYNC_SKIPPED_REASONS = {
13
- WORKSPACE_CONFIG_MISSING: "workspace-config-missing",
14
- WORKSPACE_CONFIG_INVALID: "workspace-config-invalid",
15
- WORKSPACE_ID_MISSING: "workspace-id-missing",
16
- CONTROL_PLANE_NOT_CONFIGURED: "control-plane-not-configured",
17
- CONTROL_PLANE_INVALID: "control-plane-invalid",
18
- CONTROL_PLANE_SDK_UNAVAILABLE: "control-plane-sdk-unavailable",
19
- MISSING_TOKEN_ENV: "missing-token-env",
20
- NO_EVENTS: "no-events",
21
- NO_EVENTS_ACCEPTED: "no-events-accepted",
22
- PUSH_FAILED: "push-failed"
23
- };
24
- var WU_LIFECYCLE_SYNC_RESULT_DEFAULTS = {
25
- SENT: false,
26
- ACCEPTED: 0
27
- };
28
- var WU_LIFECYCLE_SYNC_CONFIG = {
29
- CONTROL_PLANE_FIELD: "control_plane",
30
- WORKSPACE_ID_FIELD: "id",
31
- TEXT_ENCODING_UTF8: "utf-8"
32
- };
33
- var WU_LIFECYCLE_SYNC_LOG_PREFIX = "[wu-lifecycle-sync]";
34
- var WU_LIFECYCLE_EVENT_SCHEMA_VERSION = 1;
35
- var WU_LIFECYCLE_CLAIM_DEFAULTS = {
36
- ACTOR: "wu-claim-cli",
37
- SESSION_ID: "wu-claim-session"
38
- };
39
- var WU_LIFECYCLE_SPEC_HASH = {
40
- ALGORITHM: "sha256",
41
- DIGEST_ENCODING: "hex",
42
- HEX_256_REGEX: /^[a-f0-9]{64}$/
43
- };
44
-
45
- export {
46
- WU_LIFECYCLE_COMMANDS,
47
- WU_LIFECYCLE_EVENT_KINDS,
48
- WU_LIFECYCLE_SYNC_SKIPPED_REASONS,
49
- WU_LIFECYCLE_SYNC_RESULT_DEFAULTS,
50
- WU_LIFECYCLE_SYNC_CONFIG,
51
- WU_LIFECYCLE_SYNC_LOG_PREFIX,
52
- WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
53
- WU_LIFECYCLE_CLAIM_DEFAULTS,
54
- WU_LIFECYCLE_SPEC_HASH
55
- };
@@ -1,343 +0,0 @@
1
- import {
2
- findInitiative,
3
- getInitiativePhases,
4
- getInitiativeProgress,
5
- getInitiativeWUs
6
- } from "./chunk-MZ7RKIX4.js";
7
- import {
8
- OUTPUT_FORMATS
9
- } from "./chunk-NAP6CFSO.js";
10
- import {
11
- WU_OPTIONS,
12
- createWUParser,
13
- runCLI
14
- } from "./chunk-2GXVIN57.js";
15
- import {
16
- WU_STATUS
17
- } from "./chunk-V6OJGLBA.js";
18
- import {
19
- die
20
- } from "./chunk-RXRKBBSM.js";
21
-
22
- // src/initiative-status.ts
23
- function asString(value) {
24
- return typeof value === "string" ? value : "";
25
- }
26
- function asStringArray(value) {
27
- return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
28
- }
29
- function normalizeLifecycleStatus(value) {
30
- return typeof value === "string" ? value.trim().toLowerCase() : "";
31
- }
32
- function toInitiativePhases(doc) {
33
- return Array.isArray(doc.phases) ? doc.phases : [];
34
- }
35
- function hasIncompletePhase(phases) {
36
- if (!Array.isArray(phases) || phases.length === 0) {
37
- return false;
38
- }
39
- return phases.some((phase) => {
40
- if (phase == null || typeof phase !== "object") {
41
- return true;
42
- }
43
- return normalizeLifecycleStatus(phase.status) !== WU_STATUS.DONE;
44
- });
45
- }
46
- function hasAllLinkedWUsDone(progress) {
47
- if (!progress) {
48
- return false;
49
- }
50
- return progress.total > 0 && progress.done === progress.total;
51
- }
52
- function hasIncompleteLinkedWUs(progress) {
53
- if (!progress) {
54
- return false;
55
- }
56
- return progress.total > 0 && progress.done < progress.total;
57
- }
58
- function deriveInitiativeLifecycleStatus(status, phases, progress) {
59
- const normalizedStatus = normalizeLifecycleStatus(status);
60
- if (hasAllLinkedWUsDone(progress)) {
61
- return WU_STATUS.DONE;
62
- }
63
- if (normalizedStatus === WU_STATUS.DONE && hasIncompletePhase(phases)) {
64
- return WU_STATUS.IN_PROGRESS;
65
- }
66
- if (normalizedStatus === WU_STATUS.DONE && hasIncompleteLinkedWUs(progress)) {
67
- return WU_STATUS.IN_PROGRESS;
68
- }
69
- return normalizedStatus || WU_STATUS.IN_PROGRESS;
70
- }
71
- function getWUBlockers(doc) {
72
- const blockedBy = asStringArray(doc.blocked_by);
73
- if (blockedBy.length > 0) {
74
- return blockedBy;
75
- }
76
- return asStringArray(doc.dependencies);
77
- }
78
- function hasPhaseWUStatus(phaseWUs, status) {
79
- return phaseWUs.some((wu) => normalizeLifecycleStatus(wu.doc.status) === status);
80
- }
81
- function areAllPhaseWUsDone(phaseWUs) {
82
- return phaseWUs.length > 0 && phaseWUs.every((wu) => normalizeLifecycleStatus(wu.doc.status) === WU_STATUS.DONE);
83
- }
84
- function deriveInitiativePhaseStatus(status, phaseWUs) {
85
- if (areAllPhaseWUsDone(phaseWUs)) {
86
- return WU_STATUS.DONE;
87
- }
88
- if (hasPhaseWUStatus(phaseWUs, WU_STATUS.IN_PROGRESS)) {
89
- return WU_STATUS.IN_PROGRESS;
90
- }
91
- if (hasPhaseWUStatus(phaseWUs, WU_STATUS.BLOCKED)) {
92
- return WU_STATUS.BLOCKED;
93
- }
94
- if (hasPhaseWUStatus(phaseWUs, WU_STATUS.READY)) {
95
- return WU_STATUS.READY;
96
- }
97
- return normalizeLifecycleStatus(status) || WU_STATUS.IN_PROGRESS;
98
- }
99
- function priorityRank(priority) {
100
- const p = String(priority || "").toUpperCase();
101
- const map = { P0: 0, P1: 1, P2: 2, P3: 3 };
102
- return p in map ? map[p] : 9;
103
- }
104
- function isRunnableReady(wu, wuById) {
105
- if (normalizeLifecycleStatus(wu.doc.status) !== WU_STATUS.READY) return false;
106
- const blockers = getWUBlockers(wu.doc);
107
- return blockers.every((blockerId) => {
108
- const blocker = wuById.get(blockerId);
109
- return !blocker || normalizeLifecycleStatus(blocker.doc.status) === WU_STATUS.DONE;
110
- });
111
- }
112
- function renderDetailed(initiative, useColor) {
113
- const { id, doc } = initiative;
114
- const progress = getInitiativeProgress(id);
115
- const wus = getInitiativeWUs(id);
116
- const wuById = new Map(wus.map((wu) => [wu.id, wu]));
117
- const phaseGroups = getInitiativePhases(id);
118
- const phases = toInitiativePhases(doc);
119
- const status = deriveInitiativeLifecycleStatus(doc.status, phases, progress);
120
- const docTitle = asString(doc.title);
121
- const rawStatus = asString(doc.status);
122
- const normalizedRawStatus = normalizeLifecycleStatus(rawStatus);
123
- console.log(`
124
- ${id}: ${docTitle || "(untitled)"}`);
125
- console.log(
126
- `Status: ${status} | Progress: ${progress.percentage}% (${progress.done}/${progress.total} WUs)`
127
- );
128
- if (status !== normalizedRawStatus) {
129
- console.log(
130
- `Lifecycle mismatch: metadata status '${rawStatus}' is inconsistent with phase state; reporting '${status}'.`
131
- );
132
- }
133
- console.log("\nStart here:");
134
- console.log(
135
- ` 1) Plan waves (recommended): pnpm orchestrate:initiative --initiative ${id} --dry-run`
136
- );
137
- const runnableReady = wus.filter((wu) => isRunnableReady(wu, wuById)).sort((a, b) => {
138
- const byPriority = priorityRank(a.doc.priority) - priorityRank(b.doc.priority);
139
- if (byPriority !== 0) return byPriority;
140
- return a.id.localeCompare(b.id);
141
- });
142
- if (runnableReady.length > 0) {
143
- const next = runnableReady[0];
144
- if (next) {
145
- console.log(
146
- ` 2) Start next WU: pnpm wu:claim --id ${next.id} --lane "${asString(next.doc.lane)}"`
147
- );
148
- console.log(` Then cd into the created worktree (shown by wu:claim output)`);
149
- }
150
- } else if (progress.inProgress > 0) {
151
- console.log(
152
- ` 2) Continue: ${progress.inProgress} WU(s) already in progress (finish those first)`
153
- );
154
- } else if (progress.blocked > 0) {
155
- console.log(` 2) Unblock: ${progress.blocked} WU(s) blocked (resolve blockers first)`);
156
- } else {
157
- console.log(" 2) No runnable ready WUs found (check dependencies/blocked_by)");
158
- }
159
- const description = asString(doc.description);
160
- if (description) {
161
- console.log(`
162
- Description: ${description}`);
163
- }
164
- const owner = asString(doc.owner);
165
- if (owner) {
166
- console.log(`Owner: ${owner}`);
167
- }
168
- const targetDate = asString(doc.target_date);
169
- if (targetDate) {
170
- console.log(`Target: ${targetDate}`);
171
- }
172
- if (phases.length > 0) {
173
- console.log("\nPhases:");
174
- for (const phase of phases) {
175
- const phaseWUs = phaseGroups.get(phase.id) || [];
176
- const phaseStatus = formatStatus(
177
- deriveInitiativePhaseStatus(phase.status, phaseWUs),
178
- useColor
179
- );
180
- const phaseTitle = asString(phase.title) || `Phase ${phase.id}`;
181
- console.log(
182
- ` ${phase.id}. ${phaseTitle.padEnd(30)} [${phaseStatus}] ${phaseWUs.length} WUs`
183
- );
184
- }
185
- const unassigned = phaseGroups.get(null) || [];
186
- if (unassigned.length > 0) {
187
- console.log(` -. Unassigned ${unassigned.length} WUs`);
188
- }
189
- }
190
- console.log("\nWork Units by Status:");
191
- const byStatus = groupWUsByStatus(wus);
192
- for (const [status2, statusWUs] of Object.entries(byStatus)) {
193
- if (statusWUs.length > 0) {
194
- console.log(` ${capitalizeFirst(status2)} (${statusWUs.length}):`);
195
- for (const wu of statusWUs.slice(0, 5)) {
196
- console.log(` - ${wu.id}: ${truncate(asString(wu.doc.title), 50)}`);
197
- }
198
- if (statusWUs.length > 5) {
199
- console.log(` ... and ${statusWUs.length - 5} more`);
200
- }
201
- }
202
- }
203
- const successMetrics = asStringArray(doc.success_metrics);
204
- if (successMetrics.length > 0) {
205
- console.log("\nSuccess Metrics:");
206
- for (const metric of successMetrics) {
207
- console.log(` - ${metric}`);
208
- }
209
- }
210
- console.log("");
211
- }
212
- function renderJSON(initiative) {
213
- const { id, doc } = initiative;
214
- const progress = getInitiativeProgress(id);
215
- const wus = getInitiativeWUs(id);
216
- const phaseGroups = getInitiativePhases(id);
217
- const phases = toInitiativePhases(doc);
218
- const status = deriveInitiativeLifecycleStatus(doc.status, phases, progress);
219
- const output = {
220
- id,
221
- slug: asString(doc.slug),
222
- title: asString(doc.title),
223
- description: asString(doc.description),
224
- status,
225
- rawStatus: asString(doc.status),
226
- priority: asString(doc.priority),
227
- owner: asString(doc.owner),
228
- created: asString(doc.created),
229
- targetDate: asString(doc.target_date),
230
- progress: {
231
- percentage: progress.percentage,
232
- done: progress.done,
233
- inProgress: progress.inProgress,
234
- ready: progress.ready,
235
- blocked: progress.blocked,
236
- total: progress.total
237
- },
238
- phases: phases.map((phase) => {
239
- const phaseWUs = phaseGroups.get(phase.id) || [];
240
- const phaseStatus = deriveInitiativePhaseStatus(phase.status, phaseWUs);
241
- return {
242
- id: phase.id,
243
- title: asString(phase.title),
244
- status: phaseStatus,
245
- wuCount: phaseWUs.length,
246
- wus: phaseWUs.map((w) => ({
247
- id: w.id,
248
- title: asString(w.doc.title),
249
- status: normalizeLifecycleStatus(w.doc.status)
250
- }))
251
- };
252
- }),
253
- workUnits: wus.map((w) => ({
254
- id: w.id,
255
- title: asString(w.doc.title),
256
- status: normalizeLifecycleStatus(w.doc.status),
257
- phase: w.doc.phase ?? null
258
- })),
259
- successMetrics: asStringArray(doc.success_metrics),
260
- labels: asStringArray(doc.labels)
261
- };
262
- console.log(JSON.stringify(output, null, 2));
263
- }
264
- function groupWUsByStatus(wus) {
265
- const groups = {
266
- [WU_STATUS.DONE]: [],
267
- [WU_STATUS.IN_PROGRESS]: [],
268
- [WU_STATUS.READY]: [],
269
- [WU_STATUS.BLOCKED]: [],
270
- other: []
271
- };
272
- for (const wu of wus) {
273
- const status = normalizeLifecycleStatus(wu.doc.status);
274
- switch (status) {
275
- case WU_STATUS.DONE:
276
- groups[WU_STATUS.DONE].push(wu);
277
- break;
278
- case WU_STATUS.IN_PROGRESS:
279
- groups[WU_STATUS.IN_PROGRESS].push(wu);
280
- break;
281
- case WU_STATUS.READY:
282
- groups[WU_STATUS.READY].push(wu);
283
- break;
284
- case WU_STATUS.BLOCKED:
285
- groups[WU_STATUS.BLOCKED].push(wu);
286
- break;
287
- default:
288
- groups.other.push(wu);
289
- break;
290
- }
291
- }
292
- return groups;
293
- }
294
- function formatStatus(status, useColor) {
295
- if (!useColor) return status;
296
- return status;
297
- }
298
- function truncate(str, maxLen) {
299
- if (!str) return "";
300
- return str.length > maxLen ? `${str.substring(0, maxLen - 3)}...` : str;
301
- }
302
- function capitalizeFirst(str) {
303
- return str.charAt(0).toUpperCase() + str.slice(1).replace(/_/g, " ");
304
- }
305
- async function main() {
306
- const args = createWUParser({
307
- name: "initiative-status",
308
- description: "Show detailed initiative view with phases and WUs",
309
- options: [WU_OPTIONS.id, WU_OPTIONS.format, WU_OPTIONS.color],
310
- required: [],
311
- allowPositionalId: true
312
- });
313
- const initRef = args.id;
314
- if (!initRef) {
315
- die("Initiative ID or slug is required.\n\nUsage: pnpm initiative:status INIT-001");
316
- }
317
- const initiative = findInitiative(initRef);
318
- if (!initiative) {
319
- die(
320
- `Initiative not found: ${initRef}
321
-
322
- Run 'pnpm initiative:list' to see available initiatives.`
323
- );
324
- }
325
- const format = args.format || OUTPUT_FORMATS.TABLE;
326
- switch (format) {
327
- case OUTPUT_FORMATS.JSON:
328
- renderJSON(initiative);
329
- break;
330
- default:
331
- renderDetailed(initiative, Boolean(args.color));
332
- break;
333
- }
334
- }
335
- if (import.meta.main) {
336
- void runCLI(main);
337
- }
338
-
339
- export {
340
- deriveInitiativeLifecycleStatus,
341
- deriveInitiativePhaseStatus,
342
- main
343
- };
@@ -1,195 +0,0 @@
1
- import {
2
- createWUParser,
3
- runCLI,
4
- withMicroWorktree
5
- } from "./chunk-2GXVIN57.js";
6
- import {
7
- EXIT_CODES,
8
- LUMENFLOW_PATHS
9
- } from "./chunk-DWMLTXKQ.js";
10
-
11
- // src/state-emit.ts
12
- import fs from "fs/promises";
13
- import path from "path";
14
- var VALID_EMIT_TYPES = ["claim", "release", "complete"];
15
- var WU_ID_PATTERN = /^WU-\d+$/;
16
- var LOG_PREFIX = "[state:emit]";
17
- var TOOL_NAME = "state:emit";
18
- function validateParams(opts) {
19
- if (!VALID_EMIT_TYPES.includes(opts.type)) {
20
- throw new Error(
21
- `Invalid event type: '${opts.type}'. Valid types: ${VALID_EMIT_TYPES.join(", ")}`
22
- );
23
- }
24
- if (!opts.reason || opts.reason.trim().length === 0) {
25
- throw new Error("Reason is required for corrective events");
26
- }
27
- if (!WU_ID_PATTERN.test(opts.wuId)) {
28
- throw new Error(`Invalid WU ID: '${opts.wuId}'. Must match pattern WU-XXX (e.g., WU-123)`);
29
- }
30
- }
31
- function getTransactionalCommitMessage(type, wuId) {
32
- return `chore(repair): emit corrective ${type} event for ${wuId.toLowerCase()}`;
33
- }
34
- async function emitCorrectiveEvent(opts) {
35
- validateParams(opts);
36
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
37
- const event = {
38
- wuId: opts.wuId,
39
- type: opts.type,
40
- reason: opts.reason,
41
- timestamp,
42
- source: TOOL_NAME,
43
- corrective: true
44
- };
45
- if (opts.type === "claim") {
46
- if (opts.lane) event.lane = opts.lane;
47
- if (opts.title) event.title = opts.title;
48
- }
49
- const eventLine = JSON.stringify(event);
50
- await fs.mkdir(path.dirname(opts.eventsFilePath), { recursive: true });
51
- await fs.appendFile(opts.eventsFilePath, eventLine + "\n", "utf-8");
52
- await writeAuditLog(opts.auditLogPath, {
53
- tool: TOOL_NAME,
54
- status: "success",
55
- timestamp,
56
- input: {
57
- type: opts.type,
58
- wuId: opts.wuId,
59
- reason: opts.reason
60
- }
61
- });
62
- }
63
- async function emitCorrectiveEventTransactionally(opts, deps = {}) {
64
- validateParams(opts);
65
- const withMicroWorktreeImpl = deps.withMicroWorktreeImpl ?? withMicroWorktree;
66
- const emitCorrectiveEventImpl = deps.emitCorrectiveEventImpl ?? emitCorrectiveEvent;
67
- await withMicroWorktreeImpl({
68
- operation: "state-emit",
69
- id: `emit-${opts.wuId.toLowerCase()}-${opts.type}`,
70
- logPrefix: LOG_PREFIX,
71
- pushOnly: true,
72
- execute: async ({ worktreePath }) => {
73
- const eventsFilePath = path.join(worktreePath, LUMENFLOW_PATHS.WU_EVENTS);
74
- const auditLogPath = path.join(worktreePath, LUMENFLOW_PATHS.AUDIT_LOG);
75
- await emitCorrectiveEventImpl({
76
- type: opts.type,
77
- wuId: opts.wuId,
78
- reason: opts.reason,
79
- eventsFilePath,
80
- auditLogPath,
81
- lane: opts.lane,
82
- title: opts.title
83
- });
84
- return {
85
- commitMessage: getTransactionalCommitMessage(opts.type, opts.wuId),
86
- files: [LUMENFLOW_PATHS.WU_EVENTS]
87
- };
88
- }
89
- });
90
- }
91
- async function writeAuditLog(logPath, entry) {
92
- try {
93
- await fs.mkdir(path.dirname(logPath), { recursive: true });
94
- await fs.appendFile(logPath, JSON.stringify(entry) + "\n", "utf-8");
95
- } catch {
96
- }
97
- }
98
- function parseArguments() {
99
- return createWUParser({
100
- name: "state-emit",
101
- description: "Emit a corrective event to the state store",
102
- options: [
103
- {
104
- name: "type",
105
- flags: "-t, --type <type>",
106
- description: `Event type (${VALID_EMIT_TYPES.join(", ")})`
107
- },
108
- {
109
- name: "wu",
110
- flags: "--wu <wuId>",
111
- description: "Work Unit ID (e.g., WU-123)"
112
- },
113
- {
114
- name: "reason",
115
- flags: "-r, --reason <reason>",
116
- description: "Reason for the corrective event (required)"
117
- },
118
- {
119
- name: "baseDir",
120
- flags: "-b, --base-dir <path>",
121
- description: "Base directory (defaults to current directory)"
122
- },
123
- {
124
- name: "transactional",
125
- flags: "--transactional",
126
- description: "Commit corrective event via micro-worktree (push-only mode)"
127
- }
128
- ],
129
- required: [],
130
- allowPositionalId: false
131
- });
132
- }
133
- async function main() {
134
- const args = parseArguments();
135
- if (!args.type) {
136
- console.error(`${LOG_PREFIX} Error: --type is required (${VALID_EMIT_TYPES.join(", ")})`);
137
- process.exit(EXIT_CODES.ERROR);
138
- }
139
- if (!args.wu) {
140
- console.error(`${LOG_PREFIX} Error: --wu is required (e.g., WU-123)`);
141
- process.exit(EXIT_CODES.ERROR);
142
- }
143
- if (!args.reason) {
144
- console.error(`${LOG_PREFIX} Error: --reason is required`);
145
- process.exit(EXIT_CODES.ERROR);
146
- }
147
- const baseDir = args.baseDir || process.cwd();
148
- const eventsFilePath = path.join(baseDir, LUMENFLOW_PATHS.WU_EVENTS);
149
- const auditLogPath = path.join(baseDir, LUMENFLOW_PATHS.AUDIT_LOG);
150
- try {
151
- if (args.transactional) {
152
- const resolvedBaseDir = path.resolve(baseDir);
153
- const resolvedCwd = path.resolve(process.cwd());
154
- if (resolvedBaseDir !== resolvedCwd) {
155
- throw new Error(
156
- "Transactional mode requires running from target repo root; --base-dir is not supported"
157
- );
158
- }
159
- await emitCorrectiveEventTransactionally({
160
- type: args.type,
161
- wuId: args.wu,
162
- reason: args.reason
163
- });
164
- console.log(`${LOG_PREFIX} Emitted corrective '${args.type}' event for ${args.wu}`);
165
- console.log(`${LOG_PREFIX} Mode: transactional (micro-worktree push-only)`);
166
- console.log(`${LOG_PREFIX} Reason: ${args.reason}`);
167
- } else {
168
- await emitCorrectiveEvent({
169
- type: args.type,
170
- wuId: args.wu,
171
- reason: args.reason,
172
- eventsFilePath,
173
- auditLogPath
174
- });
175
- console.log(`${LOG_PREFIX} Emitted corrective '${args.type}' event for ${args.wu}`);
176
- console.log(`${LOG_PREFIX} Mode: append-only`);
177
- console.log(`${LOG_PREFIX} Reason: ${args.reason}`);
178
- console.log(`${LOG_PREFIX} Events file: ${eventsFilePath}`);
179
- }
180
- } catch (err) {
181
- const message = err instanceof Error ? err.message : String(err);
182
- console.error(`${LOG_PREFIX} Error: ${message}`);
183
- process.exit(EXIT_CODES.ERROR);
184
- }
185
- }
186
- if (import.meta.main) {
187
- void runCLI(main);
188
- }
189
-
190
- export {
191
- VALID_EMIT_TYPES,
192
- emitCorrectiveEvent,
193
- emitCorrectiveEventTransactionally,
194
- main
195
- };
@@ -1,82 +0,0 @@
1
- import {
2
- SHA256_INTEGRITY_PREFIX,
3
- computeDeterministicPackHash
4
- } from "./chunk-HANJXVKW.js";
5
- import {
6
- WU_OPTIONS,
7
- createWUParser,
8
- runCLI
9
- } from "./chunk-2GXVIN57.js";
10
-
11
- // src/pack-hash.ts
12
- import { resolve } from "path";
13
- var LOG_PREFIX = "[pack:hash]";
14
- var DEFAULT_PACKS_ROOT = "packages/@lumenflow/packs";
15
- function resolvePackRoot(options) {
16
- const { directPackRoot, packId, packsRoot } = options;
17
- if (directPackRoot) {
18
- return resolve(directPackRoot);
19
- }
20
- if (packId && packsRoot) {
21
- return resolve(packsRoot, packId);
22
- }
23
- return null;
24
- }
25
- async function computePackHash(options) {
26
- const { packRoot, hashExclusions } = options;
27
- const absolutePackRoot = resolve(packRoot);
28
- const hex = await computeDeterministicPackHash({
29
- packRoot: absolutePackRoot,
30
- exclusions: hashExclusions
31
- });
32
- return `${SHA256_INTEGRITY_PREFIX}${hex}`;
33
- }
34
- var PACK_HASH_OPTIONS = {
35
- packId: {
36
- name: "id",
37
- flags: "--id <packId>",
38
- description: "Pack ID to hash (resolves under --packs-root)"
39
- },
40
- packsRoot: {
41
- name: "packsRoot",
42
- flags: "--packs-root <dir>",
43
- description: `Root directory containing packs (default: "${DEFAULT_PACKS_ROOT}")`
44
- },
45
- packRoot: {
46
- name: "packRoot",
47
- flags: "--pack-root <dir>",
48
- description: "Direct path to pack directory (overrides --id and --packs-root)"
49
- }
50
- };
51
- async function main() {
52
- const opts = createWUParser({
53
- name: "pack-hash",
54
- description: "Compute integrity hash for a LumenFlow domain pack",
55
- options: [
56
- PACK_HASH_OPTIONS.packId,
57
- PACK_HASH_OPTIONS.packsRoot,
58
- PACK_HASH_OPTIONS.packRoot,
59
- WU_OPTIONS.force
60
- ]
61
- });
62
- const packId = opts.id;
63
- const packsRoot = opts.packsRoot ?? DEFAULT_PACKS_ROOT;
64
- const directPackRoot = opts.packRoot;
65
- const resolvedPackRoot = resolvePackRoot({ directPackRoot, packId, packsRoot });
66
- if (!resolvedPackRoot) {
67
- console.error(`${LOG_PREFIX} Error: Provide --id <packId> or --pack-root <dir>`);
68
- process.exit(1);
69
- }
70
- const hash = await computePackHash({ packRoot: resolvedPackRoot });
71
- console.log(hash);
72
- }
73
- if (import.meta.main) {
74
- void runCLI(main);
75
- }
76
-
77
- export {
78
- LOG_PREFIX,
79
- resolvePackRoot,
80
- computePackHash,
81
- main
82
- };