@lumenflow/cli 3.17.7 → 3.18.1
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.
- package/README.md +44 -43
- package/dist/chunk-2D2VOCA4.js +37 -0
- package/dist/chunk-2D5KFYGX.js +284 -0
- package/dist/chunk-2GXVIN57.js +14072 -0
- package/dist/chunk-2MQ7HZWZ.js +26 -0
- package/dist/chunk-2UFQ3A3C.js +643 -0
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-4N74J3UT.js +15 -0
- package/dist/chunk-5GTOXFYR.js +392 -0
- package/dist/chunk-5VY6MQMC.js +240 -0
- package/dist/chunk-67XVPMRY.js +1297 -0
- package/dist/chunk-6HO4GWJE.js +164 -0
- package/dist/chunk-6W5XHWYV.js +1890 -0
- package/dist/chunk-6X4EMYJQ.js +64 -0
- package/dist/chunk-6XYXI2NQ.js +772 -0
- package/dist/chunk-7ANSOV6Q.js +285 -0
- package/dist/chunk-A624LFLB.js +1380 -0
- package/dist/chunk-ADN5NHG4.js +126 -0
- package/dist/chunk-B7YJYJKG.js +33 -0
- package/dist/chunk-CCLHCPKG.js +210 -0
- package/dist/chunk-CK36VROC.js +1584 -0
- package/dist/chunk-D3UOFRSB.js +81 -0
- package/dist/chunk-DFR4DJBM.js +230 -0
- package/dist/chunk-DSYBDHYH.js +79 -0
- package/dist/chunk-DWMLTXKQ.js +1176 -0
- package/dist/chunk-E3REJTAJ.js +28 -0
- package/dist/chunk-EA3IVO64.js +633 -0
- package/dist/chunk-EK2AKZKD.js +55 -0
- package/dist/chunk-ELD7JTTT.js +343 -0
- package/dist/chunk-EX6TT2XI.js +195 -0
- package/dist/chunk-EXINSFZE.js +82 -0
- package/dist/chunk-EZ6ZBYBM.js +510 -0
- package/dist/chunk-FBKAPTJ2.js +16 -0
- package/dist/chunk-FVLV5RYH.js +1118 -0
- package/dist/chunk-GDNSBQVK.js +2485 -0
- package/dist/chunk-GPQHMBNN.js +278 -0
- package/dist/chunk-GTFJB67L.js +68 -0
- package/dist/chunk-HANJXVKW.js +1127 -0
- package/dist/chunk-HEVS5YLD.js +269 -0
- package/dist/chunk-HMEVZKPQ.js +9 -0
- package/dist/chunk-HRGSYNLM.js +3511 -0
- package/dist/chunk-ISZR5N4K.js +60 -0
- package/dist/chunk-J6SUPR2C.js +226 -0
- package/dist/chunk-JERYVEIZ.js +244 -0
- package/dist/chunk-JHHWGL2N.js +87 -0
- package/dist/chunk-JONWQUB5.js +775 -0
- package/dist/chunk-K2DIWWDM.js +1766 -0
- package/dist/chunk-KY4PGL5V.js +969 -0
- package/dist/chunk-L737LQ4C.js +1285 -0
- package/dist/chunk-LFTWYIB2.js +497 -0
- package/dist/chunk-LV47RFNJ.js +41 -0
- package/dist/chunk-MKSAITI7.js +15 -0
- package/dist/chunk-MZ7RKIX4.js +212 -0
- package/dist/chunk-NAP6CFSO.js +84 -0
- package/dist/chunk-ND6MY37M.js +16 -0
- package/dist/chunk-NMG736UR.js +683 -0
- package/dist/chunk-NRAXROED.js +32 -0
- package/dist/chunk-NRIZR3A7.js +690 -0
- package/dist/chunk-NX43BG3M.js +233 -0
- package/dist/chunk-O645XLSI.js +297 -0
- package/dist/chunk-OMJD6A3S.js +235 -0
- package/dist/chunk-QB6SJD4T.js +430 -0
- package/dist/chunk-QFSTL4J3.js +276 -0
- package/dist/chunk-QLGDFMFX.js +212 -0
- package/dist/chunk-RIAAGL2E.js +13 -0
- package/dist/chunk-RWO5XMZ6.js +86 -0
- package/dist/chunk-RXRKBBSM.js +149 -0
- package/dist/chunk-RZOZMML6.js +363 -0
- package/dist/chunk-U7I7FS7T.js +113 -0
- package/dist/chunk-UI42RODY.js +717 -0
- package/dist/chunk-UTVMVSCO.js +519 -0
- package/dist/chunk-V6OJGLBA.js +1746 -0
- package/dist/chunk-W2JHVH7D.js +152 -0
- package/dist/chunk-WD3Y7VQN.js +280 -0
- package/dist/chunk-WOCTQ5MS.js +303 -0
- package/dist/chunk-WZR3ZUNN.js +696 -0
- package/dist/chunk-XGI665H7.js +150 -0
- package/dist/chunk-XKY65P2T.js +304 -0
- package/dist/chunk-Y4CQZY65.js +57 -0
- package/dist/chunk-YFEXKLVE.js +194 -0
- package/dist/chunk-YHO3HS5X.js +287 -0
- package/dist/chunk-YLS7AZSX.js +738 -0
- package/dist/chunk-ZE473AO6.js +49 -0
- package/dist/chunk-ZF747T3O.js +644 -0
- package/dist/chunk-ZHCZHZH3.js +43 -0
- package/dist/chunk-ZZNZX2XY.js +87 -0
- package/dist/config-set.js +10 -1
- package/dist/config-set.js.map +1 -1
- package/dist/constants-7QAP3VQ4.js +23 -0
- package/dist/dist-IY3UUMWK.js +33 -0
- package/dist/gate-co-change.js +5 -2
- package/dist/gate-co-change.js.map +1 -1
- package/dist/init-detection.js +5 -3
- package/dist/init-detection.js.map +1 -1
- package/dist/init-templates.js +4 -4
- package/dist/init-templates.js.map +1 -1
- package/dist/initiative-edit.js +8 -3
- package/dist/initiative-edit.js.map +1 -1
- package/dist/initiative-plan.js +1 -1
- package/dist/initiative-plan.js.map +1 -1
- package/dist/invariants-runner-W5RGHCSU.js +27 -0
- package/dist/lane-lock-6J36HD5O.js +35 -0
- package/dist/lumenflow-upgrade.js +49 -0
- package/dist/lumenflow-upgrade.js.map +1 -1
- package/dist/mem-checkpoint-core-EANG2GVN.js +14 -0
- package/dist/mem-signal-core-2LZ2WYHW.js +19 -0
- package/dist/memory-store-OLB5FO7K.js +18 -0
- package/dist/pre-commit-check.js +1 -1
- package/dist/pre-commit-check.js.map +1 -1
- package/dist/service-6BYCOCO5.js +13 -0
- package/dist/spawn-policy-resolver-NTSZYQ6R.js +17 -0
- package/dist/spawn-task-builder-R4E2BHSW.js +22 -0
- package/dist/wu-done-pr-WLFFFEPJ.js +25 -0
- package/dist/wu-done-validation-3J5E36FE.js +30 -0
- package/dist/wu-duplicate-id-detector-5S7JHELK.js +232 -0
- package/dist/wu-edit-operations.js +4 -0
- package/dist/wu-edit-operations.js.map +1 -1
- package/dist/wu-edit-validators.js +4 -0
- package/dist/wu-edit-validators.js.map +1 -1
- package/dist/wu-edit.js +11 -0
- package/dist/wu-edit.js.map +1 -1
- package/dist/wu-spawn-strategy-resolver.js +13 -1
- package/dist/wu-spawn-strategy-resolver.js.map +1 -1
- package/package.json +8 -8
- package/packs/agent-runtime/.turbo/turbo-build.log +4 -0
- package/packs/agent-runtime/README.md +147 -0
- package/packs/agent-runtime/capability-factory.ts +104 -0
- package/packs/agent-runtime/config.schema.json +87 -0
- package/packs/agent-runtime/constants.ts +21 -0
- package/packs/agent-runtime/index.ts +11 -0
- package/packs/agent-runtime/manifest.ts +207 -0
- package/packs/agent-runtime/manifest.yaml +193 -0
- package/packs/agent-runtime/orchestration.ts +1787 -0
- package/packs/agent-runtime/pack-registration.ts +110 -0
- package/packs/agent-runtime/package.json +57 -0
- package/packs/agent-runtime/policy-factory.ts +165 -0
- package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +793 -0
- package/packs/agent-runtime/tool-impl/index.ts +5 -0
- package/packs/agent-runtime/tool-impl/provider-adapters.ts +1245 -0
- package/packs/agent-runtime/tools/index.ts +4 -0
- package/packs/agent-runtime/tools/types.ts +47 -0
- package/packs/agent-runtime/tsconfig.json +20 -0
- package/packs/agent-runtime/types.ts +128 -0
- package/packs/agent-runtime/vitest.config.ts +11 -0
- package/packs/sidekick/.turbo/turbo-build.log +1 -1
- package/packs/sidekick/.turbo/turbo-test.log +12 -0
- package/packs/sidekick/.turbo/turbo-typecheck.log +4 -0
- package/packs/sidekick/package.json +1 -1
- package/packs/software-delivery/.turbo/turbo-build.log +1 -1
- package/packs/software-delivery/.turbo/turbo-typecheck.log +4 -0
- package/packs/software-delivery/package.json +1 -1
- package/templates/core/.lumenflow/rules/wu-workflow.md.template +1 -1
- package/templates/core/ai/onboarding/first-wu-mistakes.md.template +2 -2
- package/templates/core/ai/onboarding/quick-ref-commands.md.template +1 -1
- package/templates/core/ai/onboarding/starting-prompt.md.template +1 -1
- package/templates/vendors/claude/.claude/skills/frontend-design/SKILL.md.template +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PROGRESSABLE_WU_STATUSES
|
|
3
|
+
} from "./chunk-V6OJGLBA.js";
|
|
4
|
+
|
|
5
|
+
// ../initiatives/dist/initiative-validation.js
|
|
6
|
+
var PROGRESSABLE_STATUSES = ["draft", "open"];
|
|
7
|
+
function validateInitiativeCompleteness(initiative) {
|
|
8
|
+
const warnings = [];
|
|
9
|
+
const id = initiative.id || "unknown";
|
|
10
|
+
if (!initiative.description || initiative.description.trim() === "") {
|
|
11
|
+
warnings.push(`[${id}] Initiative has no description. Add a description to explain its purpose.`);
|
|
12
|
+
}
|
|
13
|
+
if (!initiative.phases || initiative.phases.length === 0) {
|
|
14
|
+
warnings.push(`[${id}] Initiative has no phases defined. Add phases to break down the work.`);
|
|
15
|
+
}
|
|
16
|
+
if (!initiative.success_metrics || initiative.success_metrics.length === 0) {
|
|
17
|
+
warnings.push(`[${id}] Initiative has no success_metrics defined. Add metrics to measure completion.`);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
valid: true,
|
|
21
|
+
// Always valid - issues are warnings not errors
|
|
22
|
+
warnings
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function checkInitiativePhases(initiative) {
|
|
26
|
+
const hasPhases = Array.isArray(initiative.phases) && initiative.phases.length > 0;
|
|
27
|
+
const id = initiative.id || "unknown";
|
|
28
|
+
return {
|
|
29
|
+
hasPhases,
|
|
30
|
+
warning: hasPhases ? null : `Initiative ${id} has no phases defined. Consider adding phases before linking WUs.`
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function shouldProgressInitiativeStatus(initiative, wus) {
|
|
34
|
+
const currentStatus = initiative.status || "draft";
|
|
35
|
+
const initiativeId = initiative.id;
|
|
36
|
+
if (!PROGRESSABLE_STATUSES.includes(currentStatus)) {
|
|
37
|
+
return {
|
|
38
|
+
shouldProgress: false,
|
|
39
|
+
newStatus: null
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const initiativeWUs = wus.filter((wu) => wu.initiative === initiativeId);
|
|
43
|
+
const hasActiveWU = initiativeWUs.some((wu) => PROGRESSABLE_WU_STATUSES.includes(wu.status || ""));
|
|
44
|
+
if (hasActiveWU) {
|
|
45
|
+
return {
|
|
46
|
+
shouldProgress: true,
|
|
47
|
+
newStatus: "in_progress"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
shouldProgress: false,
|
|
52
|
+
newStatus: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
validateInitiativeCompleteness,
|
|
58
|
+
checkInitiativePhases,
|
|
59
|
+
shouldProgressInitiativeStatus
|
|
60
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appendNode,
|
|
3
|
+
loadMemory
|
|
4
|
+
} from "./chunk-DFR4DJBM.js";
|
|
5
|
+
import {
|
|
6
|
+
validateLaneFormat
|
|
7
|
+
} from "./chunk-JONWQUB5.js";
|
|
8
|
+
import {
|
|
9
|
+
LUMENFLOW_MEMORY_PATHS
|
|
10
|
+
} from "./chunk-4N74J3UT.js";
|
|
11
|
+
import {
|
|
12
|
+
createWuPaths
|
|
13
|
+
} from "./chunk-6HO4GWJE.js";
|
|
14
|
+
import {
|
|
15
|
+
ErrorCodes,
|
|
16
|
+
createError
|
|
17
|
+
} from "./chunk-RXRKBBSM.js";
|
|
18
|
+
|
|
19
|
+
// ../memory/dist/mem-triage-core.js
|
|
20
|
+
import fs from "fs/promises";
|
|
21
|
+
import path from "path";
|
|
22
|
+
var RELATIONSHIPS_FILE_NAME = "relationships.jsonl";
|
|
23
|
+
var DEFAULT_PRIORITY = "P2";
|
|
24
|
+
var MAX_TITLE_LENGTH = 80;
|
|
25
|
+
var PRIORITY_RANK = {
|
|
26
|
+
P0: 0,
|
|
27
|
+
P1: 1,
|
|
28
|
+
P2: 2,
|
|
29
|
+
P3: 3
|
|
30
|
+
};
|
|
31
|
+
var DEFAULT_PRIORITY_RANK = 999;
|
|
32
|
+
function getPriorityRank(node) {
|
|
33
|
+
const priority = node.metadata?.priority;
|
|
34
|
+
if (!priority) {
|
|
35
|
+
return DEFAULT_PRIORITY_RANK;
|
|
36
|
+
}
|
|
37
|
+
return PRIORITY_RANK[priority] ?? DEFAULT_PRIORITY_RANK;
|
|
38
|
+
}
|
|
39
|
+
function compareNodes(a, b) {
|
|
40
|
+
const priorityDiff = getPriorityRank(a) - getPriorityRank(b);
|
|
41
|
+
if (priorityDiff !== 0) {
|
|
42
|
+
return priorityDiff;
|
|
43
|
+
}
|
|
44
|
+
const aTime = new Date(a.created_at).getTime();
|
|
45
|
+
const bTime = new Date(b.created_at).getTime();
|
|
46
|
+
if (aTime !== bTime) {
|
|
47
|
+
return aTime - bTime;
|
|
48
|
+
}
|
|
49
|
+
return a.id.localeCompare(b.id);
|
|
50
|
+
}
|
|
51
|
+
async function loadRelationships(memoryDir) {
|
|
52
|
+
const filePath = path.join(memoryDir, RELATIONSHIPS_FILE_NAME);
|
|
53
|
+
try {
|
|
54
|
+
const content = await fs.readFile(filePath, { encoding: "utf-8" });
|
|
55
|
+
const lines = content.split("\n");
|
|
56
|
+
const relationships = [];
|
|
57
|
+
for (const line of lines) {
|
|
58
|
+
const trimmed = line.trim();
|
|
59
|
+
if (!trimmed)
|
|
60
|
+
continue;
|
|
61
|
+
try {
|
|
62
|
+
relationships.push(JSON.parse(trimmed));
|
|
63
|
+
} catch {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return relationships;
|
|
68
|
+
} catch (err) {
|
|
69
|
+
const error = err;
|
|
70
|
+
if (error.code === "ENOENT") {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function buildBlockedSet(relationships) {
|
|
77
|
+
const blocked = /* @__PURE__ */ new Set();
|
|
78
|
+
for (const rel of relationships) {
|
|
79
|
+
if (rel.type === "blocks") {
|
|
80
|
+
blocked.add(rel.to_id);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return blocked;
|
|
84
|
+
}
|
|
85
|
+
function isBlocked(node, blockedByRelationships) {
|
|
86
|
+
if (blockedByRelationships.has(node.id)) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const blockedBy = node.metadata?.blocked_by;
|
|
90
|
+
if (Array.isArray(blockedBy) && blockedBy.length > 0) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
function isClosed(node) {
|
|
96
|
+
const status = node.metadata?.status;
|
|
97
|
+
if (status === "closed" || status === "archived") {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
if (node.lifecycle === "ephemeral") {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
async function listOpenDiscoveries(baseDir, options = {}) {
|
|
106
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
107
|
+
const memory = await loadMemory(memoryDir);
|
|
108
|
+
const relationships = await loadRelationships(memoryDir);
|
|
109
|
+
const blockedByRelationships = buildBlockedSet(relationships);
|
|
110
|
+
let nodes = memory.nodes.filter((node) => node.type === "discovery");
|
|
111
|
+
nodes = nodes.filter((node) => !isBlocked(node, blockedByRelationships));
|
|
112
|
+
nodes = nodes.filter((node) => !isClosed(node));
|
|
113
|
+
if (options.wuId) {
|
|
114
|
+
if (options.wuId === "unlinked") {
|
|
115
|
+
nodes = nodes.filter((node) => !node.wu_id);
|
|
116
|
+
} else {
|
|
117
|
+
nodes = nodes.filter((node) => node.wu_id === options.wuId);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (options.tag) {
|
|
121
|
+
const filterTag = options.tag;
|
|
122
|
+
nodes = nodes.filter((node) => node.tags?.includes(filterTag));
|
|
123
|
+
}
|
|
124
|
+
return nodes.sort(compareNodes);
|
|
125
|
+
}
|
|
126
|
+
async function archiveDiscovery(baseDir, options) {
|
|
127
|
+
const { nodeId, reason } = options;
|
|
128
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
129
|
+
const memory = await loadMemory(memoryDir);
|
|
130
|
+
const node = memory.byId.get(nodeId);
|
|
131
|
+
if (!node) {
|
|
132
|
+
throw createError(ErrorCodes.NODE_NOT_FOUND, `Node not found: ${nodeId}`);
|
|
133
|
+
}
|
|
134
|
+
if (node.type !== "discovery") {
|
|
135
|
+
throw createError(ErrorCodes.VALIDATION_ERROR, `Node ${nodeId} is not a discovery (type: ${node.type})`);
|
|
136
|
+
}
|
|
137
|
+
if (node.metadata?.status === "archived" || node.metadata?.status === "closed") {
|
|
138
|
+
throw createError(ErrorCodes.ALREADY_EXISTS, `Node ${nodeId} is already archived/closed`);
|
|
139
|
+
}
|
|
140
|
+
const archivedNode = {
|
|
141
|
+
...node,
|
|
142
|
+
metadata: {
|
|
143
|
+
...node.metadata,
|
|
144
|
+
status: "archived",
|
|
145
|
+
archive_reason: reason,
|
|
146
|
+
archived_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
await appendNode(memoryDir, archivedNode);
|
|
150
|
+
return {
|
|
151
|
+
success: true,
|
|
152
|
+
nodeId
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
async function getNextWuId(baseDir) {
|
|
156
|
+
const paths = createWuPaths({ projectRoot: baseDir });
|
|
157
|
+
const wuDir = path.join(baseDir, paths.WU_DIR());
|
|
158
|
+
let maxId = 0;
|
|
159
|
+
try {
|
|
160
|
+
const files = await fs.readdir(wuDir);
|
|
161
|
+
for (const file of files) {
|
|
162
|
+
const match = file.match(/^WU-(\d+)\.yaml$/);
|
|
163
|
+
if (match && match[1]) {
|
|
164
|
+
const id = parseInt(match[1], 10);
|
|
165
|
+
if (id > maxId) {
|
|
166
|
+
maxId = id;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
} catch (err) {
|
|
171
|
+
const error = err;
|
|
172
|
+
if (error.code !== "ENOENT") {
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return `WU-${maxId + 1}`;
|
|
177
|
+
}
|
|
178
|
+
function truncateToTitle(content) {
|
|
179
|
+
const parts = content.split(/[.!?]/);
|
|
180
|
+
const firstSentence = (parts[0] ?? "").trim();
|
|
181
|
+
if (firstSentence.length <= MAX_TITLE_LENGTH) {
|
|
182
|
+
return firstSentence;
|
|
183
|
+
}
|
|
184
|
+
return firstSentence.substring(0, MAX_TITLE_LENGTH - 3) + "...";
|
|
185
|
+
}
|
|
186
|
+
async function promoteDiscovery(baseDir, options) {
|
|
187
|
+
const { nodeId, lane, title, wuId, priority, dryRun: _dryRun = false } = options;
|
|
188
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
189
|
+
try {
|
|
190
|
+
validateLaneFormat(lane);
|
|
191
|
+
} catch (err) {
|
|
192
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
193
|
+
throw createError(ErrorCodes.INVALID_LANE, `Invalid lane format: ${errMsg}`, { cause: err });
|
|
194
|
+
}
|
|
195
|
+
const memory = await loadMemory(memoryDir);
|
|
196
|
+
const node = memory.byId.get(nodeId);
|
|
197
|
+
if (!node) {
|
|
198
|
+
throw createError(ErrorCodes.NODE_NOT_FOUND, `Node not found: ${nodeId}`);
|
|
199
|
+
}
|
|
200
|
+
if (node.type !== "discovery") {
|
|
201
|
+
throw createError(ErrorCodes.VALIDATION_ERROR, `Node ${nodeId} is not a discovery (type: ${node.type})`);
|
|
202
|
+
}
|
|
203
|
+
if (node.metadata?.status === "archived" || node.metadata?.status === "closed") {
|
|
204
|
+
throw createError(ErrorCodes.ALREADY_EXISTS, `Node ${nodeId} is already archived/closed`);
|
|
205
|
+
}
|
|
206
|
+
const resolvedWuId = wuId || await getNextWuId(baseDir);
|
|
207
|
+
const resolvedTitle = title || truncateToTitle(node.content);
|
|
208
|
+
const resolvedPriority = priority || node.metadata?.priority || DEFAULT_PRIORITY;
|
|
209
|
+
const wuSpec = {
|
|
210
|
+
id: resolvedWuId,
|
|
211
|
+
title: resolvedTitle,
|
|
212
|
+
lane,
|
|
213
|
+
priority: resolvedPriority,
|
|
214
|
+
notes: `Promoted from discovery ${nodeId}`
|
|
215
|
+
};
|
|
216
|
+
return {
|
|
217
|
+
success: true,
|
|
218
|
+
wuSpec
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export {
|
|
223
|
+
listOpenDiscoveries,
|
|
224
|
+
archiveDiscovery,
|
|
225
|
+
promoteDiscovery
|
|
226
|
+
};
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WU_LIFECYCLE_CLAIM_DEFAULTS,
|
|
3
|
+
WU_LIFECYCLE_COMMANDS,
|
|
4
|
+
WU_LIFECYCLE_EVENT_KINDS,
|
|
5
|
+
WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
|
|
6
|
+
WU_LIFECYCLE_SPEC_HASH,
|
|
7
|
+
WU_LIFECYCLE_SYNC_CONFIG,
|
|
8
|
+
WU_LIFECYCLE_SYNC_LOG_PREFIX,
|
|
9
|
+
WU_LIFECYCLE_SYNC_RESULT_DEFAULTS,
|
|
10
|
+
WU_LIFECYCLE_SYNC_SKIPPED_REASONS
|
|
11
|
+
} from "./chunk-EK2AKZKD.js";
|
|
12
|
+
import {
|
|
13
|
+
CONFIG_FILES
|
|
14
|
+
} from "./chunk-DWMLTXKQ.js";
|
|
15
|
+
import {
|
|
16
|
+
ErrorCodes,
|
|
17
|
+
createError,
|
|
18
|
+
getErrorMessage
|
|
19
|
+
} from "./chunk-RXRKBBSM.js";
|
|
20
|
+
|
|
21
|
+
// src/wu-lifecycle-sync/service.ts
|
|
22
|
+
import { createHash } from "crypto";
|
|
23
|
+
import { readFileSync } from "fs";
|
|
24
|
+
|
|
25
|
+
// src/wu-lifecycle-sync/control-plane-sink.ts
|
|
26
|
+
import path from "path";
|
|
27
|
+
import { readFile } from "fs/promises";
|
|
28
|
+
import YAML from "yaml";
|
|
29
|
+
|
|
30
|
+
// src/wu-lifecycle-sync/noop-sink.ts
|
|
31
|
+
function createNoopSink(skippedReason) {
|
|
32
|
+
return {
|
|
33
|
+
async push() {
|
|
34
|
+
return {
|
|
35
|
+
sent: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.SENT,
|
|
36
|
+
accepted: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.ACCEPTED,
|
|
37
|
+
skippedReason
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/wu-lifecycle-sync/control-plane-sink.ts
|
|
44
|
+
function isRecord(value) {
|
|
45
|
+
return typeof value === "object" && value !== null;
|
|
46
|
+
}
|
|
47
|
+
function asNonEmptyString(value) {
|
|
48
|
+
if (typeof value !== "string") {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
const trimmed = value.trim();
|
|
52
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
53
|
+
}
|
|
54
|
+
function createNoopSyncResult(skippedReason) {
|
|
55
|
+
return {
|
|
56
|
+
sent: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.SENT,
|
|
57
|
+
accepted: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.ACCEPTED,
|
|
58
|
+
skippedReason
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function createParseInput(workspaceId, controlPlaneRaw) {
|
|
62
|
+
return {
|
|
63
|
+
[WU_LIFECYCLE_SYNC_CONFIG.WORKSPACE_ID_FIELD]: workspaceId,
|
|
64
|
+
[WU_LIFECYCLE_SYNC_CONFIG.CONTROL_PLANE_FIELD]: controlPlaneRaw
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function loadControlPlaneSdk(logger) {
|
|
68
|
+
try {
|
|
69
|
+
return await import("./dist-IY3UUMWK.js");
|
|
70
|
+
} catch (error) {
|
|
71
|
+
logger?.warn?.(
|
|
72
|
+
`${WU_LIFECYCLE_SYNC_LOG_PREFIX} control-plane SDK unavailable: ${getErrorMessage(error)}`
|
|
73
|
+
);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function resolveWuLifecycleEventSink(options = {}) {
|
|
78
|
+
const workspaceRoot = options.workspaceRoot ?? process.cwd();
|
|
79
|
+
const workspacePath = path.join(workspaceRoot, CONFIG_FILES.WORKSPACE_CONFIG);
|
|
80
|
+
let workspaceContent;
|
|
81
|
+
try {
|
|
82
|
+
workspaceContent = await readFile(workspacePath, WU_LIFECYCLE_SYNC_CONFIG.TEXT_ENCODING_UTF8);
|
|
83
|
+
} catch {
|
|
84
|
+
return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.WORKSPACE_CONFIG_MISSING);
|
|
85
|
+
}
|
|
86
|
+
let parsedWorkspace;
|
|
87
|
+
try {
|
|
88
|
+
parsedWorkspace = YAML.parse(workspaceContent);
|
|
89
|
+
} catch {
|
|
90
|
+
return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.WORKSPACE_CONFIG_INVALID);
|
|
91
|
+
}
|
|
92
|
+
if (!isRecord(parsedWorkspace)) {
|
|
93
|
+
return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.WORKSPACE_CONFIG_INVALID);
|
|
94
|
+
}
|
|
95
|
+
const workspaceId = asNonEmptyString(
|
|
96
|
+
Reflect.get(parsedWorkspace, WU_LIFECYCLE_SYNC_CONFIG.WORKSPACE_ID_FIELD)
|
|
97
|
+
);
|
|
98
|
+
if (!workspaceId) {
|
|
99
|
+
return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.WORKSPACE_ID_MISSING);
|
|
100
|
+
}
|
|
101
|
+
const controlPlaneRaw = Reflect.get(
|
|
102
|
+
parsedWorkspace,
|
|
103
|
+
WU_LIFECYCLE_SYNC_CONFIG.CONTROL_PLANE_FIELD
|
|
104
|
+
);
|
|
105
|
+
if (!isRecord(controlPlaneRaw)) {
|
|
106
|
+
return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.CONTROL_PLANE_NOT_CONFIGURED);
|
|
107
|
+
}
|
|
108
|
+
const controlPlaneSdk = await loadControlPlaneSdk(options.logger);
|
|
109
|
+
if (!controlPlaneSdk) {
|
|
110
|
+
return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.CONTROL_PLANE_SDK_UNAVAILABLE);
|
|
111
|
+
}
|
|
112
|
+
const { parseWorkspaceControlPlaneConfig, createHttpControlPlaneSyncPort } = controlPlaneSdk;
|
|
113
|
+
let runtimeConfig;
|
|
114
|
+
try {
|
|
115
|
+
runtimeConfig = parseWorkspaceControlPlaneConfig(
|
|
116
|
+
createParseInput(workspaceId, controlPlaneRaw)
|
|
117
|
+
);
|
|
118
|
+
} catch {
|
|
119
|
+
return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.CONTROL_PLANE_INVALID);
|
|
120
|
+
}
|
|
121
|
+
const environment = options.environment ?? process.env;
|
|
122
|
+
const tokenEnv = runtimeConfig.control_plane.auth.token_env;
|
|
123
|
+
const token = asNonEmptyString(environment[tokenEnv]);
|
|
124
|
+
if (!token) {
|
|
125
|
+
return createNoopSink(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.MISSING_TOKEN_ENV);
|
|
126
|
+
}
|
|
127
|
+
const syncPort = createHttpControlPlaneSyncPort(runtimeConfig.control_plane, options.logger, {
|
|
128
|
+
fetchFn: options.fetchFn,
|
|
129
|
+
environment,
|
|
130
|
+
timeoutMs: options.timeoutMs
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
async push(events) {
|
|
134
|
+
if (events.length === 0) {
|
|
135
|
+
return createNoopSyncResult(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.NO_EVENTS);
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const result = await syncPort.pushKernelEvents({
|
|
139
|
+
workspace_id: workspaceId,
|
|
140
|
+
events
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
sent: result.accepted > 0,
|
|
144
|
+
accepted: result.accepted,
|
|
145
|
+
...result.accepted > 0 ? {} : {
|
|
146
|
+
skippedReason: WU_LIFECYCLE_SYNC_SKIPPED_REASONS.NO_EVENTS_ACCEPTED
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
} catch (error) {
|
|
150
|
+
options.logger?.warn?.(
|
|
151
|
+
`${WU_LIFECYCLE_SYNC_LOG_PREFIX} pushKernelEvents failed: ${getErrorMessage(error)}`
|
|
152
|
+
);
|
|
153
|
+
return createNoopSyncResult(WU_LIFECYCLE_SYNC_SKIPPED_REASONS.PUSH_FAILED);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/wu-lifecycle-sync/service.ts
|
|
160
|
+
function asNonEmptyString2(value) {
|
|
161
|
+
if (typeof value !== "string") {
|
|
162
|
+
return void 0;
|
|
163
|
+
}
|
|
164
|
+
const trimmed = value.trim();
|
|
165
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
166
|
+
}
|
|
167
|
+
function createSha256Hex(input) {
|
|
168
|
+
return createHash(WU_LIFECYCLE_SPEC_HASH.ALGORITHM).update(input).digest(WU_LIFECYCLE_SPEC_HASH.DIGEST_ENCODING);
|
|
169
|
+
}
|
|
170
|
+
function resolveSpecHash(input) {
|
|
171
|
+
const explicitSpecHash = asNonEmptyString2(input.specHash);
|
|
172
|
+
if (explicitSpecHash && WU_LIFECYCLE_SPEC_HASH.HEX_256_REGEX.test(explicitSpecHash)) {
|
|
173
|
+
return explicitSpecHash;
|
|
174
|
+
}
|
|
175
|
+
const specPath = asNonEmptyString2(input.specPath);
|
|
176
|
+
if (specPath) {
|
|
177
|
+
try {
|
|
178
|
+
const fileContent = readFileSync(specPath, WU_LIFECYCLE_SYNC_CONFIG.TEXT_ENCODING_UTF8);
|
|
179
|
+
return createSha256Hex(fileContent);
|
|
180
|
+
} catch {
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return createSha256Hex(`${WU_LIFECYCLE_COMMANDS.CREATE}:${input.wuId}`);
|
|
184
|
+
}
|
|
185
|
+
function resolveTimestamp(input) {
|
|
186
|
+
return input.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
187
|
+
}
|
|
188
|
+
function buildWuLifecycleKernelEvent(input) {
|
|
189
|
+
const timestamp = resolveTimestamp(input);
|
|
190
|
+
switch (input.command) {
|
|
191
|
+
case WU_LIFECYCLE_COMMANDS.CREATE:
|
|
192
|
+
return {
|
|
193
|
+
schema_version: WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
|
|
194
|
+
kind: WU_LIFECYCLE_EVENT_KINDS.CREATE,
|
|
195
|
+
task_id: input.wuId,
|
|
196
|
+
timestamp,
|
|
197
|
+
spec_hash: resolveSpecHash(input)
|
|
198
|
+
};
|
|
199
|
+
case WU_LIFECYCLE_COMMANDS.CLAIM:
|
|
200
|
+
return {
|
|
201
|
+
schema_version: WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
|
|
202
|
+
kind: WU_LIFECYCLE_EVENT_KINDS.CLAIM,
|
|
203
|
+
task_id: input.wuId,
|
|
204
|
+
timestamp,
|
|
205
|
+
by: asNonEmptyString2(input.by) ?? WU_LIFECYCLE_CLAIM_DEFAULTS.ACTOR,
|
|
206
|
+
session_id: asNonEmptyString2(input.sessionId) ?? WU_LIFECYCLE_CLAIM_DEFAULTS.SESSION_ID
|
|
207
|
+
};
|
|
208
|
+
case WU_LIFECYCLE_COMMANDS.DONE:
|
|
209
|
+
return {
|
|
210
|
+
schema_version: WU_LIFECYCLE_EVENT_SCHEMA_VERSION,
|
|
211
|
+
kind: WU_LIFECYCLE_EVENT_KINDS.DONE,
|
|
212
|
+
task_id: input.wuId,
|
|
213
|
+
timestamp,
|
|
214
|
+
...input.evidenceRefs && input.evidenceRefs.length > 0 ? { evidence_refs: input.evidenceRefs } : {}
|
|
215
|
+
};
|
|
216
|
+
default: {
|
|
217
|
+
const exhaustiveCheck = input.command;
|
|
218
|
+
throw createError(
|
|
219
|
+
ErrorCodes.INVALID_ARGUMENT,
|
|
220
|
+
`Unsupported WU lifecycle command: ${exhaustiveCheck}`
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async function flushWuLifecycleSync(input, options = {}) {
|
|
226
|
+
const logger = options.logger;
|
|
227
|
+
try {
|
|
228
|
+
const sink = options.sink ?? await resolveWuLifecycleEventSink(options);
|
|
229
|
+
const event = buildWuLifecycleKernelEvent(input);
|
|
230
|
+
return await sink.push([event]);
|
|
231
|
+
} catch (error) {
|
|
232
|
+
logger?.warn?.(`${WU_LIFECYCLE_SYNC_LOG_PREFIX} fail-open: ${getErrorMessage(error)}`);
|
|
233
|
+
return {
|
|
234
|
+
sent: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.SENT,
|
|
235
|
+
accepted: WU_LIFECYCLE_SYNC_RESULT_DEFAULTS.ACCEPTED,
|
|
236
|
+
skippedReason: WU_LIFECYCLE_SYNC_SKIPPED_REASONS.PUSH_FAILED
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
buildWuLifecycleKernelEvent,
|
|
243
|
+
flushWuLifecycleSync
|
|
244
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadMemory
|
|
3
|
+
} from "./chunk-DFR4DJBM.js";
|
|
4
|
+
import {
|
|
5
|
+
LUMENFLOW_MEMORY_PATHS
|
|
6
|
+
} from "./chunk-4N74J3UT.js";
|
|
7
|
+
|
|
8
|
+
// ../memory/dist/mem-export-core.js
|
|
9
|
+
import path from "path";
|
|
10
|
+
function applyFilters(nodes, options) {
|
|
11
|
+
const { wuId, type, lifecycle } = options;
|
|
12
|
+
return nodes.filter((node) => {
|
|
13
|
+
if (wuId && node.wu_id !== wuId)
|
|
14
|
+
return false;
|
|
15
|
+
if (type && node.type !== type)
|
|
16
|
+
return false;
|
|
17
|
+
if (lifecycle && node.lifecycle !== lifecycle)
|
|
18
|
+
return false;
|
|
19
|
+
return true;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function formatFilters(options) {
|
|
23
|
+
const parts = [];
|
|
24
|
+
if (options.wuId)
|
|
25
|
+
parts.push(`wu=${options.wuId}`);
|
|
26
|
+
if (options.type)
|
|
27
|
+
parts.push(`type=${options.type}`);
|
|
28
|
+
if (options.lifecycle)
|
|
29
|
+
parts.push(`lifecycle=${options.lifecycle}`);
|
|
30
|
+
return parts.length === 0 ? "none" : parts.join(", ");
|
|
31
|
+
}
|
|
32
|
+
function formatMarkdown(nodes, options) {
|
|
33
|
+
const lines = [];
|
|
34
|
+
lines.push("# Memory Export");
|
|
35
|
+
lines.push(`Filters: ${formatFilters(options)}`);
|
|
36
|
+
lines.push(`Total: ${nodes.length}`);
|
|
37
|
+
lines.push("");
|
|
38
|
+
if (nodes.length === 0) {
|
|
39
|
+
lines.push("No matching nodes.");
|
|
40
|
+
return lines.join("\n");
|
|
41
|
+
}
|
|
42
|
+
for (const node of nodes) {
|
|
43
|
+
lines.push(`## ${node.id} (${node.type})`);
|
|
44
|
+
lines.push(`- Created: ${node.created_at}`);
|
|
45
|
+
lines.push(`- Lifecycle: ${node.lifecycle}`);
|
|
46
|
+
if (node.wu_id) {
|
|
47
|
+
lines.push(`- WU: ${node.wu_id}`);
|
|
48
|
+
}
|
|
49
|
+
lines.push(`- Content: ${node.content}`);
|
|
50
|
+
if (node.tags && node.tags.length > 0) {
|
|
51
|
+
lines.push(`- Tags: ${node.tags.join(", ")}`);
|
|
52
|
+
}
|
|
53
|
+
if (node.metadata && Object.keys(node.metadata).length > 0) {
|
|
54
|
+
lines.push(`- Metadata: ${JSON.stringify(node.metadata)}`);
|
|
55
|
+
}
|
|
56
|
+
lines.push("");
|
|
57
|
+
}
|
|
58
|
+
return lines.join("\n");
|
|
59
|
+
}
|
|
60
|
+
function formatJson(nodes, options) {
|
|
61
|
+
const payload = {
|
|
62
|
+
count: nodes.length,
|
|
63
|
+
filters: {
|
|
64
|
+
wuId: options.wuId ?? null,
|
|
65
|
+
type: options.type ?? null,
|
|
66
|
+
lifecycle: options.lifecycle ?? null
|
|
67
|
+
},
|
|
68
|
+
nodes
|
|
69
|
+
};
|
|
70
|
+
return JSON.stringify(payload, null, 2);
|
|
71
|
+
}
|
|
72
|
+
async function exportMemory(baseDir, options = {}) {
|
|
73
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
74
|
+
const memory = await loadMemory(memoryDir);
|
|
75
|
+
const nodes = applyFilters(memory.nodes, options);
|
|
76
|
+
const format = options.format ?? "markdown";
|
|
77
|
+
const output = format === "json" ? formatJson(nodes, options) : formatMarkdown(nodes, options);
|
|
78
|
+
return {
|
|
79
|
+
format,
|
|
80
|
+
nodes,
|
|
81
|
+
output
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
exportMemory
|
|
87
|
+
};
|