@lumenflow/cli 3.21.0 → 3.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.
- 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/constants-7QAP3VQ4.js +23 -0
- package/dist/dist-IY3UUMWK.js +33 -0
- package/dist/invariants-runner-W5RGHCSU.js +27 -0
- package/dist/lane-lock-6J36HD5O.js +35 -0
- 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/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-spawn-strategy-resolver.js +18 -5
- package/dist/wu-spawn-strategy-resolver.js.map +1 -1
- package/package.json +8 -8
- package/packs/agent-runtime/.turbo/turbo-build.log +1 -1
- package/packs/agent-runtime/.turbo/turbo-typecheck.log +4 -0
- package/packs/agent-runtime/package.json +1 -1
- 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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ErrorCodes,
|
|
3
|
+
createError
|
|
4
|
+
} from "./chunk-RXRKBBSM.js";
|
|
5
|
+
|
|
6
|
+
// src/template-directory-resolver.ts
|
|
7
|
+
import * as fs from "fs";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
var CLI_SCOPE_DIR = "@lumenflow";
|
|
11
|
+
var CLI_PACKAGE_DIR = "cli";
|
|
12
|
+
var TEMPLATES_DIR = "templates";
|
|
13
|
+
var PACKAGES_DIR = "packages";
|
|
14
|
+
function collectAncestorDirectories(startDir) {
|
|
15
|
+
const directories = [];
|
|
16
|
+
let current = path.resolve(startDir);
|
|
17
|
+
while (true) {
|
|
18
|
+
directories.push(current);
|
|
19
|
+
const parent = path.dirname(current);
|
|
20
|
+
if (parent === current) {
|
|
21
|
+
return directories;
|
|
22
|
+
}
|
|
23
|
+
current = parent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function isCliPackageRoot(candidate) {
|
|
27
|
+
return path.basename(candidate) === CLI_PACKAGE_DIR && path.basename(path.dirname(candidate)) === CLI_SCOPE_DIR;
|
|
28
|
+
}
|
|
29
|
+
function collectCwdCandidates(cwd) {
|
|
30
|
+
const candidates = [];
|
|
31
|
+
for (const directory of collectAncestorDirectories(cwd)) {
|
|
32
|
+
if (isCliPackageRoot(directory)) {
|
|
33
|
+
candidates.push(path.join(directory, TEMPLATES_DIR));
|
|
34
|
+
}
|
|
35
|
+
candidates.push(
|
|
36
|
+
path.join(directory, PACKAGES_DIR, CLI_SCOPE_DIR, CLI_PACKAGE_DIR, TEMPLATES_DIR)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return candidates;
|
|
40
|
+
}
|
|
41
|
+
function collectModuleCandidates(moduleUrl) {
|
|
42
|
+
const modulePath = fileURLToPath(moduleUrl);
|
|
43
|
+
const moduleDir = path.dirname(modulePath);
|
|
44
|
+
const packageRoot = path.resolve(moduleDir, "..");
|
|
45
|
+
return [path.join(packageRoot, TEMPLATES_DIR)];
|
|
46
|
+
}
|
|
47
|
+
function dedupeCandidates(candidates) {
|
|
48
|
+
const seen = /* @__PURE__ */ new Set();
|
|
49
|
+
const unique = [];
|
|
50
|
+
for (const candidate of candidates) {
|
|
51
|
+
const normalized = path.resolve(candidate);
|
|
52
|
+
if (seen.has(normalized)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
seen.add(normalized);
|
|
56
|
+
unique.push(normalized);
|
|
57
|
+
}
|
|
58
|
+
return unique;
|
|
59
|
+
}
|
|
60
|
+
function resolveCliTemplatesDir(options = {}) {
|
|
61
|
+
const existsSync2 = options.existsSync ?? fs.existsSync;
|
|
62
|
+
const cwd = options.cwd ?? process.cwd();
|
|
63
|
+
const moduleUrl = options.moduleUrl ?? import.meta.url;
|
|
64
|
+
const candidates = dedupeCandidates([
|
|
65
|
+
...collectCwdCandidates(cwd),
|
|
66
|
+
...collectModuleCandidates(moduleUrl)
|
|
67
|
+
]);
|
|
68
|
+
for (const candidate of candidates) {
|
|
69
|
+
if (existsSync2(candidate)) {
|
|
70
|
+
return candidate;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
throw createError(
|
|
74
|
+
ErrorCodes.FILE_NOT_FOUND,
|
|
75
|
+
`Templates directory not found. Checked: ${candidates.join(", ")}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
resolveCliTemplatesDir
|
|
81
|
+
};
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ErrorCodes,
|
|
3
|
+
createError
|
|
4
|
+
} from "./chunk-RXRKBBSM.js";
|
|
5
|
+
|
|
6
|
+
// ../memory/dist/memory-store.js
|
|
7
|
+
import fs from "fs/promises";
|
|
8
|
+
import path from "path";
|
|
9
|
+
|
|
10
|
+
// ../memory/dist/memory-schema.js
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
var MEMORY_NODE_TYPES = ["session", "discovery", "checkpoint", "note", "summary"];
|
|
13
|
+
var MEMORY_LIFECYCLES = ["ephemeral", "session", "wu", "project"];
|
|
14
|
+
var RELATIONSHIP_TYPES = ["blocks", "parent_child", "related", "discovered_from"];
|
|
15
|
+
var MEMORY_PATTERNS = {
|
|
16
|
+
/** Memory ID format: mem-[a-z0-9]{4} */
|
|
17
|
+
MEMORY_ID: /^mem-[a-z0-9]{4}$/,
|
|
18
|
+
/** WU ID format (reused from wu-schema) */
|
|
19
|
+
WU_ID: /^WU-\d+$/
|
|
20
|
+
};
|
|
21
|
+
var ERROR_MESSAGES = {
|
|
22
|
+
MEMORY_ID: "ID must match pattern mem-[a-z0-9]{4} (e.g., mem-abc1)",
|
|
23
|
+
NODE_TYPE: `Type must be one of: ${MEMORY_NODE_TYPES.join(", ")}`,
|
|
24
|
+
LIFECYCLE: `Lifecycle must be one of: ${MEMORY_LIFECYCLES.join(", ")}`,
|
|
25
|
+
RELATIONSHIP_TYPE: `Type must be one of: ${RELATIONSHIP_TYPES.join(", ")}`,
|
|
26
|
+
WU_ID: "WU ID must match pattern WU-XXX (e.g., WU-1462)",
|
|
27
|
+
CONTENT_REQUIRED: "Content is required",
|
|
28
|
+
DATETIME_REQUIRED: "Created timestamp is required"
|
|
29
|
+
};
|
|
30
|
+
var MemoryNodeSchema = z.object({
|
|
31
|
+
/** Memory node identifier (mem-[a-z0-9]{4}) */
|
|
32
|
+
id: z.string().regex(MEMORY_PATTERNS.MEMORY_ID, { message: ERROR_MESSAGES.MEMORY_ID }),
|
|
33
|
+
/** Node type classification */
|
|
34
|
+
type: z.enum(MEMORY_NODE_TYPES, {
|
|
35
|
+
error: ERROR_MESSAGES.NODE_TYPE
|
|
36
|
+
}),
|
|
37
|
+
/** Lifecycle duration */
|
|
38
|
+
lifecycle: z.enum(MEMORY_LIFECYCLES, {
|
|
39
|
+
error: ERROR_MESSAGES.LIFECYCLE
|
|
40
|
+
}),
|
|
41
|
+
/** Node content (required, non-empty) */
|
|
42
|
+
content: z.string().min(1, { message: ERROR_MESSAGES.CONTENT_REQUIRED }),
|
|
43
|
+
/** Creation timestamp (ISO 8601 datetime) */
|
|
44
|
+
created_at: z.string().datetime({ message: ERROR_MESSAGES.DATETIME_REQUIRED }),
|
|
45
|
+
/** Last update timestamp (optional, ISO 8601 datetime) */
|
|
46
|
+
updated_at: z.string().datetime().optional(),
|
|
47
|
+
/** Associated WU ID (optional) */
|
|
48
|
+
wu_id: z.string().regex(MEMORY_PATTERNS.WU_ID, { message: ERROR_MESSAGES.WU_ID }).optional(),
|
|
49
|
+
/** Session ID this node belongs to (optional, UUID) */
|
|
50
|
+
session_id: z.string().uuid().optional(),
|
|
51
|
+
/** Arbitrary metadata (optional) */
|
|
52
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
53
|
+
/** Tags for categorization (optional) */
|
|
54
|
+
tags: z.array(z.string()).optional()
|
|
55
|
+
});
|
|
56
|
+
var RelationshipSchema = z.object({
|
|
57
|
+
/** Source node ID (mem-[a-z0-9]{4}) */
|
|
58
|
+
from_id: z.string().regex(MEMORY_PATTERNS.MEMORY_ID, { message: ERROR_MESSAGES.MEMORY_ID }),
|
|
59
|
+
/** Target node ID (mem-[a-z0-9]{4}) */
|
|
60
|
+
to_id: z.string().regex(MEMORY_PATTERNS.MEMORY_ID, { message: ERROR_MESSAGES.MEMORY_ID }),
|
|
61
|
+
/** Relationship type */
|
|
62
|
+
type: z.enum(RELATIONSHIP_TYPES, {
|
|
63
|
+
error: ERROR_MESSAGES.RELATIONSHIP_TYPE
|
|
64
|
+
}),
|
|
65
|
+
/** Creation timestamp (optional, ISO 8601 datetime) */
|
|
66
|
+
created_at: z.string().datetime().optional(),
|
|
67
|
+
/** Arbitrary metadata (optional) */
|
|
68
|
+
metadata: z.record(z.string(), z.unknown()).optional()
|
|
69
|
+
});
|
|
70
|
+
function validateMemoryNode(data) {
|
|
71
|
+
return MemoryNodeSchema.safeParse(data);
|
|
72
|
+
}
|
|
73
|
+
function validateRelationship(data) {
|
|
74
|
+
return RelationshipSchema.safeParse(data);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ../memory/dist/memory-store.js
|
|
78
|
+
var MEMORY_FILE_NAME = "memory.jsonl";
|
|
79
|
+
var PRIORITY_RANK = {
|
|
80
|
+
P0: 0,
|
|
81
|
+
P1: 1,
|
|
82
|
+
P2: 2,
|
|
83
|
+
P3: 3
|
|
84
|
+
};
|
|
85
|
+
var DEFAULT_PRIORITY_RANK = 999;
|
|
86
|
+
function getPriorityRank(node) {
|
|
87
|
+
const priority = node.metadata?.priority;
|
|
88
|
+
if (!priority) {
|
|
89
|
+
return DEFAULT_PRIORITY_RANK;
|
|
90
|
+
}
|
|
91
|
+
return PRIORITY_RANK[priority] ?? DEFAULT_PRIORITY_RANK;
|
|
92
|
+
}
|
|
93
|
+
function compareNodes(a, b) {
|
|
94
|
+
const priorityDiff = getPriorityRank(a) - getPriorityRank(b);
|
|
95
|
+
if (priorityDiff !== 0) {
|
|
96
|
+
return priorityDiff;
|
|
97
|
+
}
|
|
98
|
+
const aTime = new Date(a.created_at).getTime();
|
|
99
|
+
const bTime = new Date(b.created_at).getTime();
|
|
100
|
+
if (aTime !== bTime) {
|
|
101
|
+
return aTime - bTime;
|
|
102
|
+
}
|
|
103
|
+
return a.id.localeCompare(b.id);
|
|
104
|
+
}
|
|
105
|
+
function isNodeArchived(node) {
|
|
106
|
+
return node.metadata?.status === "archived";
|
|
107
|
+
}
|
|
108
|
+
async function loadMemory(baseDir, options = {}) {
|
|
109
|
+
const { includeArchived = false } = options;
|
|
110
|
+
const filePath = path.join(baseDir, MEMORY_FILE_NAME);
|
|
111
|
+
const content = await readMemoryFileOrEmpty(filePath);
|
|
112
|
+
if (content === null) {
|
|
113
|
+
return createEmptyIndexedMemory();
|
|
114
|
+
}
|
|
115
|
+
return parseAndIndexMemory(content, includeArchived);
|
|
116
|
+
}
|
|
117
|
+
async function readMemoryFileOrEmpty(filePath) {
|
|
118
|
+
try {
|
|
119
|
+
return await fs.readFile(filePath, { encoding: "utf-8" });
|
|
120
|
+
} catch (err) {
|
|
121
|
+
const error = err;
|
|
122
|
+
if (error.code === "ENOENT") {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function createEmptyIndexedMemory() {
|
|
129
|
+
return {
|
|
130
|
+
nodes: [],
|
|
131
|
+
byId: /* @__PURE__ */ new Map(),
|
|
132
|
+
byWu: /* @__PURE__ */ new Map()
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function parseAndValidateLine(line, lineNumber) {
|
|
136
|
+
let parsed;
|
|
137
|
+
try {
|
|
138
|
+
parsed = JSON.parse(line);
|
|
139
|
+
} catch (err) {
|
|
140
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
141
|
+
throw createError(ErrorCodes.PARSE_ERROR, `Malformed JSON on line ${lineNumber}: ${errMsg}`, {
|
|
142
|
+
cause: err
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const validation = validateMemoryNode(parsed);
|
|
146
|
+
if (!validation.success) {
|
|
147
|
+
const issues = validation.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join(", ");
|
|
148
|
+
throw createError(ErrorCodes.VALIDATION_ERROR, `Validation error on line ${lineNumber}: ${issues}`);
|
|
149
|
+
}
|
|
150
|
+
return validation.data;
|
|
151
|
+
}
|
|
152
|
+
function indexNodeByWu(result, node) {
|
|
153
|
+
if (!node.wu_id)
|
|
154
|
+
return;
|
|
155
|
+
if (!result.byWu.has(node.wu_id)) {
|
|
156
|
+
result.byWu.set(node.wu_id, []);
|
|
157
|
+
}
|
|
158
|
+
const wuNodes = result.byWu.get(node.wu_id);
|
|
159
|
+
if (wuNodes) {
|
|
160
|
+
wuNodes.push(node);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function parseAndIndexMemory(content, includeArchived) {
|
|
164
|
+
const result = createEmptyIndexedMemory();
|
|
165
|
+
const lines = content.split("\n");
|
|
166
|
+
const allParsed = [];
|
|
167
|
+
for (let i = 0; i < lines.length; i++) {
|
|
168
|
+
const line = lines[i]?.trim() ?? "";
|
|
169
|
+
if (!line)
|
|
170
|
+
continue;
|
|
171
|
+
const node = parseAndValidateLine(line, i + 1);
|
|
172
|
+
allParsed.push(node);
|
|
173
|
+
result.byId.set(node.id, node);
|
|
174
|
+
}
|
|
175
|
+
const seen = /* @__PURE__ */ new Set();
|
|
176
|
+
for (const node of allParsed) {
|
|
177
|
+
if (seen.has(node.id))
|
|
178
|
+
continue;
|
|
179
|
+
const latestVersion = result.byId.get(node.id);
|
|
180
|
+
if (!latestVersion)
|
|
181
|
+
continue;
|
|
182
|
+
seen.add(node.id);
|
|
183
|
+
if (!includeArchived && isNodeArchived(latestVersion)) {
|
|
184
|
+
result.byId.delete(node.id);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
result.nodes.push(latestVersion);
|
|
188
|
+
result.byId.set(node.id, latestVersion);
|
|
189
|
+
indexNodeByWu(result, latestVersion);
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
async function loadMemoryAll(baseDir) {
|
|
194
|
+
return loadMemory(baseDir, { includeArchived: true });
|
|
195
|
+
}
|
|
196
|
+
async function appendNode(baseDir, node) {
|
|
197
|
+
const validation = validateMemoryNode(node);
|
|
198
|
+
if (!validation.success) {
|
|
199
|
+
const issues = validation.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join(", ");
|
|
200
|
+
throw createError(ErrorCodes.VALIDATION_ERROR, `Validation error: ${issues}`);
|
|
201
|
+
}
|
|
202
|
+
const filePath = path.join(baseDir, MEMORY_FILE_NAME);
|
|
203
|
+
const line = JSON.stringify(node) + "\n";
|
|
204
|
+
await fs.appendFile(filePath, line, { encoding: "utf-8" });
|
|
205
|
+
return node;
|
|
206
|
+
}
|
|
207
|
+
async function queryReady(baseDir, wuId, options = {}) {
|
|
208
|
+
const { includeArchived = false } = options;
|
|
209
|
+
const memory = await loadMemory(baseDir, { includeArchived });
|
|
210
|
+
const wuNodes = memory.byWu.get(wuId) ?? [];
|
|
211
|
+
return [...wuNodes].sort(compareNodes);
|
|
212
|
+
}
|
|
213
|
+
async function queryByWu(baseDir, wuId, options = {}) {
|
|
214
|
+
const { includeArchived = false } = options;
|
|
215
|
+
const memory = await loadMemory(baseDir, { includeArchived });
|
|
216
|
+
return memory.byWu.get(wuId) ?? [];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export {
|
|
220
|
+
MEMORY_NODE_TYPES,
|
|
221
|
+
MEMORY_PATTERNS,
|
|
222
|
+
validateMemoryNode,
|
|
223
|
+
validateRelationship,
|
|
224
|
+
MEMORY_FILE_NAME,
|
|
225
|
+
loadMemory,
|
|
226
|
+
loadMemoryAll,
|
|
227
|
+
appendNode,
|
|
228
|
+
queryReady,
|
|
229
|
+
queryByWu
|
|
230
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SIZING_GUIDE_REF
|
|
3
|
+
} from "./chunk-DWMLTXKQ.js";
|
|
4
|
+
|
|
5
|
+
// src/wu-sizing-validation.ts
|
|
6
|
+
var SIZING_STRATEGIES = [
|
|
7
|
+
"single-session",
|
|
8
|
+
"checkpoint-resume",
|
|
9
|
+
"orchestrator-worker",
|
|
10
|
+
"decomposition"
|
|
11
|
+
];
|
|
12
|
+
var SIZING_EXCEPTION_TYPES = ["docs-only", "shallow-multi-file"];
|
|
13
|
+
var SIZING_THRESHOLDS = {
|
|
14
|
+
SIMPLE: { files: 20, tool_calls: 50 },
|
|
15
|
+
MEDIUM: { files: 50, tool_calls: 100 },
|
|
16
|
+
OVERSIZED: { files: 100, tool_calls: 200 },
|
|
17
|
+
/** Docs-only exception thresholds (section 1.1) */
|
|
18
|
+
DOCS_ONLY: { files: 40, tool_calls: 50 }
|
|
19
|
+
};
|
|
20
|
+
function validateSizingEstimate(estimate) {
|
|
21
|
+
if (estimate === void 0) {
|
|
22
|
+
return { valid: true, errors: [] };
|
|
23
|
+
}
|
|
24
|
+
const errors = [];
|
|
25
|
+
if (typeof estimate.estimated_files !== "number" || estimate.estimated_files < 0) {
|
|
26
|
+
errors.push("sizing_estimate.estimated_files must be a non-negative number");
|
|
27
|
+
}
|
|
28
|
+
if (typeof estimate.estimated_tool_calls !== "number" || estimate.estimated_tool_calls < 0) {
|
|
29
|
+
errors.push("sizing_estimate.estimated_tool_calls must be a non-negative number");
|
|
30
|
+
}
|
|
31
|
+
if (!SIZING_STRATEGIES.includes(estimate.strategy)) {
|
|
32
|
+
errors.push(`sizing_estimate.strategy must be one of: ${SIZING_STRATEGIES.join(", ")}`);
|
|
33
|
+
}
|
|
34
|
+
if (estimate.exception_type !== void 0) {
|
|
35
|
+
if (!SIZING_EXCEPTION_TYPES.includes(estimate.exception_type)) {
|
|
36
|
+
errors.push(
|
|
37
|
+
`sizing_estimate.exception_type must be one of: ${SIZING_EXCEPTION_TYPES.join(", ")}`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (!estimate.exception_reason || estimate.exception_reason.trim().length === 0) {
|
|
41
|
+
errors.push("sizing_estimate.exception_reason is required when exception_type is set");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return { valid: errors.length === 0, errors };
|
|
45
|
+
}
|
|
46
|
+
function hasValidException(estimate) {
|
|
47
|
+
return estimate.exception_type !== void 0 && estimate.exception_reason !== void 0 && estimate.exception_reason.trim().length > 0;
|
|
48
|
+
}
|
|
49
|
+
function checkSizingAdvisory(estimate) {
|
|
50
|
+
if (estimate === void 0) {
|
|
51
|
+
return { oversize: false, warnings: [] };
|
|
52
|
+
}
|
|
53
|
+
if (hasValidException(estimate)) {
|
|
54
|
+
return { oversize: false, warnings: [] };
|
|
55
|
+
}
|
|
56
|
+
const warnings = [];
|
|
57
|
+
if (estimate.estimated_files > SIZING_THRESHOLDS.OVERSIZED.files || estimate.estimated_tool_calls > SIZING_THRESHOLDS.OVERSIZED.tool_calls) {
|
|
58
|
+
warnings.push(
|
|
59
|
+
`Sizing estimate exceeds OVERSIZED threshold (${estimate.estimated_files} files, ${estimate.estimated_tool_calls} tool calls). This WU MUST be split per ${SIZING_GUIDE_REF}.`
|
|
60
|
+
);
|
|
61
|
+
return { oversize: true, warnings };
|
|
62
|
+
}
|
|
63
|
+
if (estimate.estimated_files > SIZING_THRESHOLDS.SIMPLE.files) {
|
|
64
|
+
warnings.push(
|
|
65
|
+
`sizing: estimated_files (${estimate.estimated_files}) exceeds Simple threshold (${SIZING_THRESHOLDS.SIMPLE.files}). Consider adding exception_type/exception_reason or splitting the WU. See ${SIZING_GUIDE_REF}.`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (estimate.estimated_tool_calls > SIZING_THRESHOLDS.SIMPLE.tool_calls) {
|
|
69
|
+
warnings.push(
|
|
70
|
+
`sizing: estimated_tool_calls (${estimate.estimated_tool_calls}) exceeds Simple threshold (${SIZING_THRESHOLDS.SIMPLE.tool_calls}). Consider checkpoint-resume strategy or splitting the WU. See ${SIZING_GUIDE_REF}.`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return { oversize: warnings.length > 0, warnings };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
validateSizingEstimate,
|
|
78
|
+
checkSizingAdvisory
|
|
79
|
+
};
|