@lumenflow/cli 4.20.2 → 4.22.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 (131) hide show
  1. package/README.md +30 -27
  2. package/dist/config-set.js +54 -36
  3. package/dist/config-set.js.map +1 -1
  4. package/dist/delegation-list.js +86 -53
  5. package/dist/delegation-list.js.map +1 -1
  6. package/dist/gate-conditional.js +476 -0
  7. package/dist/gate-conditional.js.map +1 -0
  8. package/dist/gates-plan-resolvers.js +24 -1
  9. package/dist/gates-plan-resolvers.js.map +1 -1
  10. package/dist/init-templates.js +13 -0
  11. package/dist/init-templates.js.map +1 -1
  12. package/dist/initiative-create.js +1 -1
  13. package/dist/orchestrate-init-status.js +24 -31
  14. package/dist/orchestrate-init-status.js.map +1 -1
  15. package/dist/orchestrate-initiative.js +31 -2
  16. package/dist/orchestrate-initiative.js.map +1 -1
  17. package/dist/orchestrate-monitor.js +433 -1
  18. package/dist/orchestrate-monitor.js.map +1 -1
  19. package/dist/public-manifest.js +11 -4
  20. package/dist/public-manifest.js.map +1 -1
  21. package/package.json +9 -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 +6 -3
  29. package/templates/core/ai/onboarding/first-wu-mistakes.md.template +2 -2
  30. package/templates/core/ai/onboarding/initiative-orchestration.md.template +83 -27
  31. package/templates/core/ai/onboarding/quick-ref-commands.md.template +9 -5
  32. package/templates/core/ai/onboarding/starting-prompt.md.template +1 -1
  33. package/templates/core/ai/onboarding/vendor-support.md.template +13 -0
  34. package/dist/chunk-2D2VOCA4.js +0 -37
  35. package/dist/chunk-2D5KFYGX.js +0 -284
  36. package/dist/chunk-2GXVIN57.js +0 -14072
  37. package/dist/chunk-2MQ7HZWZ.js +0 -26
  38. package/dist/chunk-2UFQ3A3C.js +0 -643
  39. package/dist/chunk-3RG5ZIWI.js +0 -10
  40. package/dist/chunk-4N74J3UT.js +0 -15
  41. package/dist/chunk-5GTOXFYR.js +0 -392
  42. package/dist/chunk-5VY6MQMC.js +0 -240
  43. package/dist/chunk-67XVPMRY.js +0 -1297
  44. package/dist/chunk-6HO4GWJE.js +0 -164
  45. package/dist/chunk-6W5XHWYV.js +0 -1890
  46. package/dist/chunk-6X4EMYJQ.js +0 -64
  47. package/dist/chunk-6XYXI2NQ.js +0 -772
  48. package/dist/chunk-7ANSOV6Q.js +0 -285
  49. package/dist/chunk-A624LFLB.js +0 -1380
  50. package/dist/chunk-ADN5NHG4.js +0 -126
  51. package/dist/chunk-B7YJYJKG.js +0 -33
  52. package/dist/chunk-CCLHCPKG.js +0 -210
  53. package/dist/chunk-CK36VROC.js +0 -1584
  54. package/dist/chunk-D3UOFRSB.js +0 -81
  55. package/dist/chunk-DFR4DJBM.js +0 -230
  56. package/dist/chunk-DSYBDHYH.js +0 -79
  57. package/dist/chunk-DWMLTXKQ.js +0 -1176
  58. package/dist/chunk-E3REJTAJ.js +0 -28
  59. package/dist/chunk-EA3IVO64.js +0 -633
  60. package/dist/chunk-EK2AKZKD.js +0 -55
  61. package/dist/chunk-ELD7JTTT.js +0 -343
  62. package/dist/chunk-EX6TT2XI.js +0 -195
  63. package/dist/chunk-EXINSFZE.js +0 -82
  64. package/dist/chunk-EZ6ZBYBM.js +0 -510
  65. package/dist/chunk-FBKAPTJ2.js +0 -16
  66. package/dist/chunk-FVLV5RYH.js +0 -1118
  67. package/dist/chunk-GDNSBQVK.js +0 -2485
  68. package/dist/chunk-GPQHMBNN.js +0 -278
  69. package/dist/chunk-GTFJB67L.js +0 -68
  70. package/dist/chunk-HANJXVKW.js +0 -1127
  71. package/dist/chunk-HEVS5YLD.js +0 -269
  72. package/dist/chunk-HMEVZKPQ.js +0 -9
  73. package/dist/chunk-HRGSYNLM.js +0 -3511
  74. package/dist/chunk-ISZR5N4K.js +0 -60
  75. package/dist/chunk-J6SUPR2C.js +0 -226
  76. package/dist/chunk-JERYVEIZ.js +0 -244
  77. package/dist/chunk-JHHWGL2N.js +0 -87
  78. package/dist/chunk-JONWQUB5.js +0 -775
  79. package/dist/chunk-K2DIWWDM.js +0 -1766
  80. package/dist/chunk-KY4PGL5V.js +0 -969
  81. package/dist/chunk-L737LQ4C.js +0 -1285
  82. package/dist/chunk-LFTWYIB2.js +0 -497
  83. package/dist/chunk-LV47RFNJ.js +0 -41
  84. package/dist/chunk-MKSAITI7.js +0 -15
  85. package/dist/chunk-MZ7RKIX4.js +0 -212
  86. package/dist/chunk-NAP6CFSO.js +0 -84
  87. package/dist/chunk-ND6MY37M.js +0 -16
  88. package/dist/chunk-NMG736UR.js +0 -683
  89. package/dist/chunk-NRAXROED.js +0 -32
  90. package/dist/chunk-NRIZR3A7.js +0 -690
  91. package/dist/chunk-NX43BG3M.js +0 -233
  92. package/dist/chunk-O645XLSI.js +0 -297
  93. package/dist/chunk-OMJD6A3S.js +0 -235
  94. package/dist/chunk-QB6SJD4T.js +0 -430
  95. package/dist/chunk-QFSTL4J3.js +0 -276
  96. package/dist/chunk-QLGDFMFX.js +0 -212
  97. package/dist/chunk-RIAAGL2E.js +0 -13
  98. package/dist/chunk-RWO5XMZ6.js +0 -86
  99. package/dist/chunk-RXRKBBSM.js +0 -149
  100. package/dist/chunk-RZOZMML6.js +0 -363
  101. package/dist/chunk-U7I7FS7T.js +0 -113
  102. package/dist/chunk-UI42RODY.js +0 -717
  103. package/dist/chunk-UTVMVSCO.js +0 -519
  104. package/dist/chunk-V6OJGLBA.js +0 -1746
  105. package/dist/chunk-W2JHVH7D.js +0 -152
  106. package/dist/chunk-WD3Y7VQN.js +0 -280
  107. package/dist/chunk-WOCTQ5MS.js +0 -303
  108. package/dist/chunk-WZR3ZUNN.js +0 -696
  109. package/dist/chunk-XGI665H7.js +0 -150
  110. package/dist/chunk-XKY65P2T.js +0 -304
  111. package/dist/chunk-Y4CQZY65.js +0 -57
  112. package/dist/chunk-YFEXKLVE.js +0 -194
  113. package/dist/chunk-YHO3HS5X.js +0 -287
  114. package/dist/chunk-YLS7AZSX.js +0 -738
  115. package/dist/chunk-ZE473AO6.js +0 -49
  116. package/dist/chunk-ZF747T3O.js +0 -644
  117. package/dist/chunk-ZHCZHZH3.js +0 -43
  118. package/dist/chunk-ZZNZX2XY.js +0 -87
  119. package/dist/constants-7QAP3VQ4.js +0 -23
  120. package/dist/dist-IY3UUMWK.js +0 -33
  121. package/dist/invariants-runner-W5RGHCSU.js +0 -27
  122. package/dist/lane-lock-6J36HD5O.js +0 -35
  123. package/dist/mem-checkpoint-core-EANG2GVN.js +0 -14
  124. package/dist/mem-signal-core-2LZ2WYHW.js +0 -19
  125. package/dist/memory-store-OLB5FO7K.js +0 -18
  126. package/dist/service-6BYCOCO5.js +0 -13
  127. package/dist/spawn-policy-resolver-NTSZYQ6R.js +0 -17
  128. package/dist/spawn-task-builder-R4E2BHSW.js +0 -22
  129. package/dist/wu-done-pr-WLFFFEPJ.js +0 -25
  130. package/dist/wu-done-validation-3J5E36FE.js +0 -30
  131. package/dist/wu-duplicate-id-detector-5S7JHELK.js +0 -232
@@ -1,285 +0,0 @@
1
- import {
2
- DEFAULT_HALF_LIFE_MS,
3
- computeDecayScore
4
- } from "./chunk-ZE473AO6.js";
5
- import {
6
- MEMORY_FILE_NAME,
7
- MEMORY_PATTERNS,
8
- loadMemory
9
- } from "./chunk-DFR4DJBM.js";
10
- import {
11
- LUMENFLOW_MEMORY_PATHS
12
- } from "./chunk-4N74J3UT.js";
13
- import {
14
- ErrorCodes,
15
- createError
16
- } from "./chunk-RXRKBBSM.js";
17
-
18
- // ../memory/dist/mem-context-core.js
19
- import path2 from "path";
20
-
21
- // ../memory/dist/decay/access-tracking.js
22
- import fs from "fs/promises";
23
- import path from "path";
24
- async function writeMemoryFile(baseDir, nodes) {
25
- const filePath = path.join(baseDir, MEMORY_FILE_NAME);
26
- const content = nodes.map((n) => JSON.stringify(n)).join("\n") + (nodes.length > 0 ? "\n" : "");
27
- await fs.writeFile(filePath, content, { encoding: "utf-8" });
28
- }
29
- function updateNodeAccess(node, now = Date.now(), halfLifeMs = DEFAULT_HALF_LIFE_MS) {
30
- const timestamp = new Date(now).toISOString();
31
- const existingAccess = node.metadata?.access;
32
- const currentCount = existingAccess?.count ?? 0;
33
- const newAccess = {
34
- count: currentCount + 1,
35
- last_accessed_at: timestamp
36
- };
37
- const updatedNodeForScoring = {
38
- ...node,
39
- metadata: {
40
- ...node.metadata,
41
- access: newAccess
42
- }
43
- };
44
- const decayScore = computeDecayScore(updatedNodeForScoring, { now, halfLifeMs });
45
- const newDecay = {
46
- score: decayScore,
47
- computed_at: timestamp
48
- };
49
- return {
50
- ...node,
51
- metadata: {
52
- ...node.metadata,
53
- access: newAccess,
54
- decay: newDecay
55
- }
56
- };
57
- }
58
- async function recordAccessBatch(baseDir, nodeIds, options = {}) {
59
- const { now = Date.now(), halfLifeMs = DEFAULT_HALF_LIFE_MS } = options;
60
- const memory = await loadMemory(baseDir);
61
- const updatedNodes = [];
62
- const nodeIdSet = new Set(nodeIds);
63
- const allNodes = memory.nodes.map((node) => {
64
- if (nodeIdSet.has(node.id)) {
65
- const updated = updateNodeAccess(node, now, halfLifeMs);
66
- updatedNodes.push(updated);
67
- return updated;
68
- }
69
- return node;
70
- });
71
- if (updatedNodes.length > 0) {
72
- await writeMemoryFile(baseDir, allNodes);
73
- }
74
- return updatedNodes;
75
- }
76
-
77
- // ../memory/dist/mem-context-core.js
78
- var DEFAULT_MAX_SIZE = 4096;
79
- var DEFAULT_MAX_PROJECT_NODES = 10;
80
- var DEFAULT_MAX_RECENT_SUMMARIES = 5;
81
- var ERROR_MESSAGES = {
82
- WU_ID_REQUIRED: "wuId is required",
83
- WU_ID_EMPTY: "wuId cannot be empty",
84
- WU_ID_INVALID: "Invalid WU ID format. Expected pattern: WU-XXX (e.g., WU-1234)"
85
- };
86
- var SECTION_HEADERS = {
87
- PROJECT_PROFILE: "## Project Profile",
88
- SUMMARIES: "## Summaries",
89
- WU_CONTEXT: "## WU Context",
90
- DISCOVERIES: "## Discoveries"
91
- };
92
- function validateWuId(wuId) {
93
- if (wuId == null) {
94
- throw createError(ErrorCodes.VALIDATION_ERROR, ERROR_MESSAGES.WU_ID_REQUIRED);
95
- }
96
- if (wuId === "") {
97
- throw createError(ErrorCodes.VALIDATION_ERROR, ERROR_MESSAGES.WU_ID_EMPTY);
98
- }
99
- if (!MEMORY_PATTERNS.WU_ID.test(wuId)) {
100
- throw createError(ErrorCodes.INVALID_WU_ID, ERROR_MESSAGES.WU_ID_INVALID);
101
- }
102
- }
103
- function compareByRecency(a, b) {
104
- const aTime = new Date(a.created_at).getTime();
105
- const bTime = new Date(b.created_at).getTime();
106
- if (aTime !== bTime) {
107
- return bTime - aTime;
108
- }
109
- return a.id.localeCompare(b.id);
110
- }
111
- function createCompareByDecay(now, halfLifeMs) {
112
- return (a, b) => {
113
- const aScore = computeDecayScore(a, { now, halfLifeMs });
114
- const bScore = computeDecayScore(b, { now, halfLifeMs });
115
- if (aScore !== bScore) {
116
- return bScore - aScore;
117
- }
118
- return a.id.localeCompare(b.id);
119
- };
120
- }
121
- function filterByLifecycle(nodes, lifecycle) {
122
- return nodes.filter((node) => node.lifecycle === lifecycle);
123
- }
124
- function filterByWuId(nodes, wuId) {
125
- return nodes.filter((node) => node.wu_id === wuId);
126
- }
127
- function filterByType(nodes, type) {
128
- return nodes.filter((node) => node.type === type);
129
- }
130
- function filterByLane(nodes, lane) {
131
- if (!lane) {
132
- return nodes;
133
- }
134
- return nodes.filter((node) => {
135
- const nodeLane = node.metadata?.lane;
136
- return !nodeLane || nodeLane === lane;
137
- });
138
- }
139
- function limitNodes(nodes, limit) {
140
- if (limit === void 0 || limit <= 0) {
141
- return nodes;
142
- }
143
- return nodes.slice(0, limit);
144
- }
145
- function formatNode(node) {
146
- const timestamp = new Date(node.created_at).toISOString().split("T")[0];
147
- return `- [${node.id}] (${timestamp}): ${node.content}`;
148
- }
149
- function formatSection(header, nodes) {
150
- if (nodes.length === 0) {
151
- return "";
152
- }
153
- const lines = [header, ""];
154
- for (const node of nodes) {
155
- lines.push(formatNode(node));
156
- }
157
- lines.push("");
158
- return lines.join("\n");
159
- }
160
- function buildHeader(wuId) {
161
- return `<!-- mem:context for ${wuId} -->
162
-
163
- `;
164
- }
165
- function createEmptyResult() {
166
- return {
167
- success: true,
168
- contextBlock: "",
169
- stats: {
170
- totalNodes: 0,
171
- byType: {},
172
- truncated: false,
173
- size: 0
174
- }
175
- };
176
- }
177
- function addSectionIfNotEmpty(sections, header, nodes) {
178
- const section = formatSection(header, nodes);
179
- if (section) {
180
- sections.push(section);
181
- }
182
- }
183
- function truncateToSize(contextBlock, maxSize) {
184
- if (contextBlock.length <= maxSize) {
185
- return { content: contextBlock, truncated: false };
186
- }
187
- const lines = contextBlock.split("\n");
188
- let currentSize = 0;
189
- const truncatedLines = [];
190
- let truncated = false;
191
- for (const line of lines) {
192
- const lineSize = line.length + 1;
193
- if (currentSize + lineSize > maxSize) {
194
- truncated = true;
195
- break;
196
- }
197
- truncatedLines.push(line);
198
- currentSize += lineSize;
199
- }
200
- if (truncated) {
201
- truncatedLines.push("");
202
- truncatedLines.push("<!-- truncated - context exceeded max size -->");
203
- }
204
- return { content: truncatedLines.join("\n"), truncated };
205
- }
206
- async function generateContext(baseDir, options) {
207
- const {
208
- wuId,
209
- maxSize = DEFAULT_MAX_SIZE,
210
- sortByDecay = false,
211
- trackAccess = false,
212
- halfLifeMs = DEFAULT_HALF_LIFE_MS,
213
- now = Date.now(),
214
- // WU-1281: New options for lane filtering and limits
215
- lane,
216
- maxRecentSummaries = DEFAULT_MAX_RECENT_SUMMARIES,
217
- maxProjectNodes = DEFAULT_MAX_PROJECT_NODES
218
- } = options;
219
- validateWuId(wuId);
220
- const memoryDir = path2.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
221
- const allNodes = await loadNodesOrEmpty(memoryDir);
222
- if (allNodes.length === 0) {
223
- return createEmptyResult();
224
- }
225
- const sortComparator = sortByDecay ? createCompareByDecay(now, halfLifeMs) : compareByRecency;
226
- const summaryNodes = limitNodes([...filterByWuId(filterByType(allNodes, "summary"), wuId)].sort(sortComparator), maxRecentSummaries);
227
- const wuContextNodes = [...filterByWuId(allNodes, wuId)].filter((node) => node.type !== "summary" && node.type !== "discovery").sort(sortComparator);
228
- const discoveryNodes = [...filterByWuId(filterByType(allNodes, "discovery"), wuId)].sort(sortComparator);
229
- const projectNodes = limitNodes(filterByLane([...filterByLifecycle(allNodes, "project")].sort(sortComparator), lane), maxProjectNodes);
230
- const sections = [buildHeader(wuId)];
231
- addSectionIfNotEmpty(sections, SECTION_HEADERS.WU_CONTEXT, wuContextNodes);
232
- addSectionIfNotEmpty(sections, SECTION_HEADERS.SUMMARIES, summaryNodes);
233
- addSectionIfNotEmpty(sections, SECTION_HEADERS.DISCOVERIES, discoveryNodes);
234
- addSectionIfNotEmpty(sections, SECTION_HEADERS.PROJECT_PROFILE, projectNodes);
235
- if (sections.length === 1) {
236
- return createEmptyResult();
237
- }
238
- const rawContextBlock = sections.join("");
239
- const { content: contextBlock, truncated } = truncateToSize(rawContextBlock, maxSize);
240
- const selectedNodes = [...wuContextNodes, ...summaryNodes, ...discoveryNodes, ...projectNodes];
241
- const byType = {};
242
- for (const node of selectedNodes) {
243
- byType[node.type] = (byType[node.type] || 0) + 1;
244
- }
245
- const accessTracked = await trackAccessIfEnabled(trackAccess, selectedNodes, memoryDir, now, halfLifeMs);
246
- return {
247
- success: true,
248
- contextBlock,
249
- stats: {
250
- totalNodes: selectedNodes.length,
251
- byType,
252
- truncated,
253
- size: contextBlock.length,
254
- ...trackAccess ? { accessTracked } : {}
255
- }
256
- };
257
- }
258
- async function loadNodesOrEmpty(memoryDir) {
259
- try {
260
- const memory = await loadMemory(memoryDir);
261
- return memory.nodes;
262
- } catch (error) {
263
- const err = error;
264
- if (err.code === "ENOENT") {
265
- return [];
266
- }
267
- throw error;
268
- }
269
- }
270
- async function trackAccessIfEnabled(trackAccess, nodes, memoryDir, now, halfLifeMs) {
271
- if (!trackAccess || nodes.length === 0) {
272
- return 0;
273
- }
274
- try {
275
- const nodeIds = nodes.map((n) => n.id);
276
- const tracked = await recordAccessBatch(memoryDir, nodeIds, { now, halfLifeMs });
277
- return tracked.length;
278
- } catch {
279
- return 0;
280
- }
281
- }
282
-
283
- export {
284
- generateContext
285
- };